Why the PendingIntent doesn't send back my custom Extras setup for the Intent?

后端 未结 5 746
甜味超标
甜味超标 2020-12-01 13:51

This questions somehow relates to the question when I was looking to get the extras back in startActivityForResult but now I face another challenge.

I have subscribe

5条回答
  •  猫巷女王i
    2020-12-01 14:13

    The key is to set the extras and the unique action into the intent before calling

    PendingIntent sender=PendingIntent.getService(this, 0, intent, 0);
    

    if you set the extras and action into the intent after calling the above, it won't work. This will not work:

    Intent intent;  
    PendingIntent sender=PendingIntent.getService(this, 0,   
       intent=new Intent(this, PlacesProximityHandlerService.class), 0);  
    
    intent.setAction("PlacesProximityHandlerService");  
    intent.putExtra("lat", objPlace.getLat());  
    

提交回复
热议问题