If the amount of news is very low, you can use the notifications as spoken, but, as I believe, the RSS feed can have a lot of things to notify, it would populate the list of notifications if you want to display them one at a time.
You can’t click toasts, you can create an action with a special theme and emulate Toast behavior.
Detailed instructions
Ok, here we go! =)
To make things clear, I ended up writing a complete example of an application that acts as a toast.
The first thing we need is a class that will act as our Toast. This class will do nothing but show itself and finish after a certain time. You can handle other events to suit your needs, but this is minimally necessary to reproduce Toast behavior.
package com.rchiossi.popup; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.widget.TextView; public class MyPopup extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_popup); String message = getIntent().getStringExtra("message"); TextView messageView = (TextView) findViewById(R.id.message); messageView.setText(message); Handler handler = new Handler(); long delay = 1000; handler.postDelayed(new Runnable() { @Override public void run() { MyPopup.this.finish(); } }, delay); } }
As you can see, this class gets a String that was passed as Extra for the intention that triggered the action, sets the text to display, and sets a 1000 ms timer for the finish () method to be called. The display time can be adjusted to better suit the user interface.
The layout for this operation is very simple:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@android:drawable/toast_frame"/> </RelativeLayout>
This layout is a blank screen with text in the center. The trick here is to set the TextView background as "@android: drawable / toast_frame", which is the default background for toasts.
And now, to give it the final touch, you need to set the theme in AndroidManifest.xml to set the background of the application as transparent and remove the title.
<activity android:name=".MyPopup" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar"> </activity>
The trick here is the android: theme property. Theme.Translucent.NoTitleBar will give us an action with a transparent background and no title. Thus, when displaying activity, only Toast text and background are displayed.
Ok, now you have a fake toast, locked and loaded. But how to use it ?! First, we create a dummy application for our popup. You will not need this in your project, since your own class will run Toast.
package com.rchiossi.popup; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class Main extends Activity { private int mCount = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(Main.this,MyPopup.class); intent.putExtra("message", "My popup number " + mCount); mCount++; startActivity(intent); } }); } }
This application is basically just a button that, when clicked, shows you a toast with a message. As you can see, to tell your Toast application which message to display, we use the Intent.putExtra(name,message) method. This data is saved when MyPopup starts using the Intent.getStringExtra(name) method.
You can get the source code of my example: http://www.mediafire.com/file/7vmuy8244vwh4dk/PopItUp.zip
I hope this helps you. =)