0

工作我想的时候推送通知特定类型的挖掘开始一个新的活动。我已经扩展了ParsePushBroadcastReceiver类(我正在使用Parse)并重写onPushOpen方法。startActivity不推处理

当我在推水龙头,下面的代码不会被调用:

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

但没有任何反应。我的活动已在AndroidManifest中成功注册。我怎样才能成功开始活动?

+0

'App.context ==' –

+0

@MD正如我已经解释了这个问题,它的应用程序上下文。 –

+1

@CanPoyrazoğlu:简单的问题是:**为什么不使用'context'这是onReceive'的'第一个参数或'启动活动onPushOpen'方法** –

回答

1

大概App.context造成问题。

使用ContextonPushOpen方法来创建意图和访问startActivity活动方法的参数:

Intent postIntent = new Intent(context, SinglePostActivity.class); 
.... 
postIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
context.startActivity(postIntent);