Android Notification Vibration/LED doesn't work?
Hi I have looked at the documentation about notifications but it is of no help. I followed the advice and applied it to the following class: (the issue is commented) I wanted to apply a vibration and/LED accompanying the status bar notification( status bar notification does work). When I follow the documentation advice, it states I have to insert :otification.defaults |= Notification.DEFAULT_VIBRATE; But I get an error saying that notification cannot be resolved to a variable and if I change "notification" to note.notification, I don't get any notification at all. The application only runs If I delete the lines I've commented for you. I am not sure where I am going wrong? Thanks.
public class ReminderService extends WakeReminderIntentService {
public ReminderService() {
super("ReminderService");
}
@Override
void doReminderWork(Intent intent) {
Log.d("ReminderService", "Doing work.");
Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_开发者_StackOverflowROWID);
NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, ReminderEditActivity.class);
notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId);
PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
Notification note=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_task_message), System.currentTimeMillis());
note.setLatestEventInfo(this, getString(R.string.notify_new_task_title), getString(R.string.notify_new_task_message), pi);
note.defaults |= Notification.DEFAULT_SOUND;
//This is where I'm having problems
**notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 300;
notification.ledOffMS = 1000;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;**
note.flags |= Notification.FLAG_AUTO_CANCEL;
Where exactly do you define notification? Your Notification instance is the note object, notificiation is thus undefined.
To solve your problem, just replace all notification reference with note.
精彩评论