我想使用解析推送通知服務發送自定義數據,但從包中提取時始終返回空值。無法讀取解析推送通知包數據
自定義廣播接收器:
@Override
public void onReceive(Context context, Intent intent) {
Log.e("Receiver","Invoked");
Bundle bundle = intent.getExtras();
Intent contentIntent = new Intent(context, MainPage.class);
String alertMsg = bundle.getString("heading"); //never get this value
String urlString = bundle.getString("dataString"); //never get this value
contentIntent.putExtra(EXTRA_URL, urlString);
PendingIntent pendingIntent = PendingIntent.getActivity(context,
NOTIFY_REQUEST_CODE, contentIntent, PendingIntent.FLAG_ONE_SHOT);
showNotification(context, notificationId, alertMsg, pendingIntent);
}
艙單申報:
<receiver
android:name=".receiver.NotificationReceiver"
android:exported="false">
<intent-filter>
<action android:name="link_notification"/>
</intent-filter>
</receiver>
,我從parse儀表盤發出以下JSON:
{ "dataString": "objectId", "heading": "type", "action": "link_notification" }
當我記錄捆綁數據時,我能夠看到標題和dataString,但無法訪問它。該包總是返回null。
請幫忙! 謝謝。
什麼是在其中與json字符串配對的鍵的名稱? – AabidMulani 2014-10-17 14:05:53