Hi,
I am trying to set an automatic notification to the ticket text when a
broadcast receiver class returns a certain result. Here is what I
have so far:
public class PriceCheck extends BroadcastReceiver{
int alarmCount = 0;
public void onReceive(Context context, Intent intent)
{
do something
if (alarmCount > 0) {
String message = "!!! Price Alarm !!!";
Notifier notice = new Notifier();
Intent noticeIntent = new Intent(context, Another.class);
notice.setNotice(context, noticeIntent, R.string.limit_detect,
R.drawable.icon, message, true);
}
}
public class Notifier extends Activity{
private static final String TAG = "Notifier";
NotificationManager nm;
String tickerText;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
nm =
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
}
public void setNotice(Context ctx, Intent intent, int noticeId, int
icon, String messageText, boolean showTicker) {
// In this sample, we'll use the same text for the ticker and
the expanded notification
CharSequence text = messageText;
Log.v(TAG, "Text: " + text);
// choose the ticker text
if (showTicker = true) {
tickerText = messageText;
}
else {
tickerText = null;
}
// Set the icon, scrolling text and timestamp
Log.v(TAG, "Icon id is: " + icon);
Log.v(TAG, "TickerText is: " + tickerText + " , SystemTime is: "
+ System.currentTimeMillis());
Notification notification = new Notification(icon, tickerText,
System.currentTimeMillis());
// The PendingIntent to launch our activity if the user
selects this notification
if (ctx == null) {
Log.v(TAG, "Context is null");
}
PendingIntent contentIntent = PendingIntent.getActivity(ctx,
0,
intent, 0);
// Set the info for the views that show in the notification
panel.
notification.setLatestEventInfo(ctx, messageText,
text, contentIntent);
// Send the notification.
// We use a layout id because it is a unique number. We use
it later to cancel.
nm.notify(noticeId, notification);
}
}
The last line in the second class gives me a null pointer exception:
"nm.notify(noticeId, notification);"
I know that most of the stuff is received. How could I check that the
context has all information required? Does anybody know what I am
doing wrong?
Thanks for your input,
AusSeattle
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---