一些额外的东西是null,但其他的工作

时间:2015-05-24 13:28:37

标签: android android-intent

我正在尝试将Extra发送给intent

Intent i = new Intent(this, OpenBroadcastReceiver.class);
i.putExtra("url", url);
i.putExtra("lid", lid);
i.putExtra("regId", regId);
PendingIntent contentIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, i, 0);

我得到了:

public void onReceive(Context context, Intent intent) {
    final ShareExternalServer appUtil = new ShareExternalServer();
    Bundle extra=intent.getExtras();
    final String lid = extra.getString("lid");
    Log.e("AppUtil", "Receive! LID="+lid);
    final String url = extra.getString("url");
    final String regId = extra.getString("regId");
    Log.e("AppUtil", "Receive! URL="+url);
    Log.e("AppUtil", "Receive! regId="+regId);

...

E/AppUtil﹕ Receive! LID=null
E/AppUtil﹕ Receive! URL=https://pushall.ru/
E/AppUtil﹕ Receive! regId=APA91bGCpJWveKUgm0

一切正常 - 盖子不要发送。所有字符串。

1 个答案:

答案 0 :(得分:0)

对于广播需要

Intent intent = new Intent();
intent.setAction("com.bupyc.pushall.app.CANCEL");

http://www.techotopia.com/index.php/Android_Broadcast_Intents_and_Broadcast_Receivers