Hi,
I'm trying to launch a service from another service with certain extras. However, I can't retrieve those extras in the launched service, .getIntExtra
returns a NullPointerException.
This is how I launch the service:
Intent serviceIntent = new Intent(context, RefreshService.class);
serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
PendingIntent contentIntent = PendingIntent.getService(this, 0, serviceIntent, 0);
updateViews.setOnClickPendingIntent(R.id.btnRefresh, contentIntent);
And this how I'm trying to receive the extras in the started service:
@Override
public void onStart(Intent intent, int startId){
super.onStart(intent, startId);
mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
}
In my example, mAppWidgetId
always resorts to the default value -1.
What am I doing wrong?
Thanks for your help,
Nick