我有一个启动广播接收器的警报管理器。这是我的广播接收器:
public class AlarmBrodcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
showNotification(context);
}
private void showNotification(Context context) {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(context, MyActivity.class), 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(0)
.setContentTitle("My notification")
.setContentText("Hello World!");
mBuilder.setContentIntent(contentIntent);
mBuilder.setDefaults(Notification.DEFAULT_SOUND);
mBuilder.setAutoCancel(true);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
}
}
广播准时开始,但没有通知,只有声音。文本在哪里?怎么了?是因为我使用的是API 10和支持库吗?
发布于 2012-10-17 07:21:13
哦,我找到问题了。问题是在.setSmallIcon(0)...When中我设置了一些真实的资源,它的ok,通知出现...
https://stackoverflow.com/questions/12924835
复制相似问题