I am always getting null, when getting parcelable object from RemoteViewsService
in onReceive()
method of AppWidgetProvider
.
I tried it, passing string
and int
and it worked perfectly but not incase of parcelable
.
StackWidgetProvider.java extends AppWidgetProvider
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(INTENT_ACTION)){
Artwork artwork = (Artwork) intent.getParcelableExtra(EXTRA_ART);
Log.e("Intent","->"+artwork.getTitle());
Intent showArtDetail = new Intent(context, ArtsDetailsActivity.class);
showArtDetail.putExtra(ArtsDetailsActivity.TAG_ARTWORK, artwork);
showArtDetail.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(showArtDetail);
}
super.onReceive(context, intent);
}
StackWidgetService.java extends RemoteServiceView
Bundle extras = new Bundle();
extras.putParcelable(StackWidgetProvider.EXTRA_ART, artwork);
Intent fillInIntent = new Intent();
fillInIntent.putExtras(extras);
remoteViews.setOnClickFillInIntent(R.id.widget_item, fillInIntent);