0

包 com.mmu.mpo;

导入android.app.Notification;导入android.app.NotificationManager;导入 android.app.PendingIntent;导入 android.content.BroadcastReceiver;导入android.content.Context;导入android.content.Intent;导入android.net.Uri;导入android.os.Bundle;导入 android.widget.Toast;公共类 AlarmReceiver 扩展 BroadcastReceiver { private static int NOTIFICATION_ID = 1;

@Override public void onReceive(Context context, Intent intent) {

  NotificationManager manger = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);      Notification

notification = new Notification(R.drawable.ic_launcher, "Combi Note", System.currentTimeMillis());

          PendingIntent contentIntent = PendingIntent.getActivity(context, NOTIFICATION_ID, new Intent(context, AlarmReceiver.class), 0);
          Bundle extras=intent.getExtras();       String title=extras.getString("title");         String

note=extras.getString("note");

          notification.setLatestEventInfo(context, title, "Venue : " + note, contentIntent);      //notification.flags =

Notification.FLAG_INSISTENT;notification.defaults |= Notification.DEFAULT_SOUND;

  manger.notify(NOTIFICATION_ID++, notification);

      }

 };
4

1 回答 1

1

试试这是否有帮助!

Context context = getApplicationContext();

CharSequence contentTitle = "Notification";

CharSequence contentText = "New Notification";

final Notification notifyDetails = new Notification(R.drawable.icon, "Consider yourself notified", System.currentTimeMillis());

Intent notifyIntent = new Intent(context, YourActivity.class);

PendingIntent intent = PendingIntent.getActivity(context, 0, notifyIntent,  PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_AUTO_CANCEL);

notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);

((NotificationManager)getSystemService(NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, notifyDetails);
于 2012-12-31T14:44:32.777 回答