I launch an activity from my widget using an Intent with some extra, anyway I can only get the Intent when the activity is in background.. How can I get the Intent when activity is created? Tried with this.getIntent() but extras are null.
Thanks in advance
Call
getIntent()
on theActivity
.One possibility is that you are arranging for an existing instance of the activity to return to the foreground (e.g., including
FLAG_ACTIVITY_REORDER_TO_FRONT
), in which case you will need to overrideonNewIntent()
and collect theIntent
there.Another possibility is that you originally created a
PendingIntent
for theIntent
with no extras, then later tried to create a newPendingIntent
on an equivalentIntent
(e.g., identifying the same activity) and included extras. In that case, you need to includeFLAG_UPDATE_CURRENT
orFLAG_CANCEL_CURRENT
when creating thePendingIntent
, so your new/changed extras are taken into account.getIntent(); is the proper way to get the intent that launched the Activity. It is possible that extras are null. That meens, that there are no extras :)
Are you sure that you added your extras?