極光推送廣播接收器 跳轉~

1:先在AndroidManifest定義廣播靜態接收器

<receiver
    android:name="You receiverName"
    android:enabled="true">
    <intent-filter>
        <action android:name="cn.jpush.android.intent.REGISTRATION" />
        <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
        <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
        <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />

        <category android:name="You Package/>
    </intent-filter>
</receiver>

2:寫一個自己的廣播接收器

if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
    System.out.println("收到了通知");
    // 在這裏可以做些統計,或者做些其他工作
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
    System.out.println("用戶點擊打開了通知");
    // 在這裏可以自己寫代碼去定義用戶點擊後的行爲
    Intent i = new Intent(context, Activity.class);  //自定義打開的界面
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章