刚刚接触极光推送,想写一套基础类方便调用。在编写自定义BroadcastReceiver的时候出现个问题,希望高手能帮忙解惑。
在XML里定义的receiver并设置好filter
<action ndroid:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />这条是可监听的,在点击通知栏后会根据代码跳转到相应的页面。
现在改为在代码中定义intentfilter
public void registerMessageReceiver() {
receiver = new MyReceiver(Test2Activity.class);
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(JPushInterface.ACTION_REGISTRATION_ID);
filter.addAction(JPushInterface.ACTION_MESSAGE_RECEIVED);
filter.addAction(JPushInterface.ACTION_NOTIFICATION_RECEIVED);
filter.addAction(JPushInterface.ACTION_NOTIFICATION_OPENED);
filter.addAction(JPushInterface.ACTION_CONNECTION_CHANGE);
filter.addCategory("com.cncsys.jpushlibrary");
registerReceiver(receiver, filter);
}
消息是可以正常拦截到的,但当点击通知栏时并没有执行onReceive(注意,是没有执行onReceive,而不是action没有监听到,说明并没有通过Intentfilter拦截到),尝试了很多种方法都没有搞定。不知道哪位高人能够指点一二
在XML里定义的receiver并设置好filter
<action ndroid:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />这条是可监听的,在点击通知栏后会根据代码跳转到相应的页面。
现在改为在代码中定义intentfilter
public void registerMessageReceiver() {
receiver = new MyReceiver(Test2Activity.class);
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(JPushInterface.ACTION_REGISTRATION_ID);
filter.addAction(JPushInterface.ACTION_MESSAGE_RECEIVED);
filter.addAction(JPushInterface.ACTION_NOTIFICATION_RECEIVED);
filter.addAction(JPushInterface.ACTION_NOTIFICATION_OPENED);
filter.addAction(JPushInterface.ACTION_CONNECTION_CHANGE);
filter.addCategory("com.cncsys.jpushlibrary");
registerReceiver(receiver, filter);
}
消息是可以正常拦截到的,但当点击通知栏时并没有执行onReceive(注意,是没有执行onReceive,而不是action没有监听到,说明并没有通过Intentfilter拦截到),尝试了很多种方法都没有搞定。不知道哪位高人能够指点一二