小编Amr*_*rit的帖子

通知单击不在Nexus电话上启动给定的活动

我正在使用此代码显示本地通知,当通知出现时,点击通知想要启动ListActivity,但是在ListActiviy点击通知时不启动Google nexus设备,但在其他设备上此代码运行良好.

    Intent notificationIntent = new Intent(context,
            ListActivity.class);
    notificationIntent.putExtra("clicked", "Notification Clicked");
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |   Intent.FLAG_ACTIVITY_SINGLE_TOP);   // To open only one activity on launch.
    PendingIntent pIntent = PendingIntent.getActivity(context, reqCode,
            notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationManager nM = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder notify = new NotificationCompat.Builder(
            context);

    notify.setContentIntent(pIntent);
    notify.setSmallIcon(R.drawable.app_icon);
    notify.setContentTitle("Hello World");
    notify.setContentText("");
    notify.setAutoCancel(true);
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    notify.setSound(alarmSound);
    notify.setLights(Color.BLUE, 500, 1000);
    nM.notify(reqCode, notify.build());
Run Code Online (Sandbox Code Playgroud)

未启动活动时添加logcat:

03-26 14:22:35.893: W/ActivityManager(515): Permission Denial: starting Intent { cmp=com.x.y/.music.ui.PlaybackActivity bnds=[42,101][636,186] (has extras) } from null (pid=-1, uid=10121) not exported from …
Run Code Online (Sandbox Code Playgroud)

events notifications android click

21
推荐指数
3
解决办法
2万
查看次数

标签 统计

android ×1

click ×1

events ×1

notifications ×1