0

当点击特定类型的推送通知时,我正在尝试开始一项新活动。我已经扩展了ParsePushBroadcastReceiver类(我正在使用 Parse)和覆盖onPushOpen的方法。

当我点击推送时,会调用以下代码:

Intent postIntent = new Intent(App.context, SinglePostActivity.class);
postIntent.putExtra(SinglePostActivity.ARG_POST_ID, postId);
context.startActivity(postIntent);

但什么也没有发生。我在 AndroidManifest 中成功注册了我的活动。如何成功启动活动?

4

1 回答 1

1

可能App.context导致问题。

使用方法的Context参数onPushOpen来创建 Intent 和访问startActivityActivity 方法:

Intent postIntent = new Intent(context, SinglePostActivity.class);
....
postIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(postIntent);
于 2015-04-17T11:28:07.027 回答