[Android] Pass variable/intent to an activity when launched from a Widget
- by Pelly
Hi,
Currently within an activity in my application I can call another activity and pass a variable to it in the following manner:
Intent myIntent = new Intent(parentView.getContext(), ShowStations.class);
myIntent.putExtra("stationName", stations[position].StationName);
startActivity(myIntent);
This works fine, but now I want to be able to do the same from my Widget. Currently this code works fine for launching a specific activity from my widget:
Intent WidgetIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("grell.com", "grell.com.FavStations"));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, WidgetIntent, 0);
updateViews.setOnClickPendingIntent(R.id.widget_main, pendingIntent);
So now I am wondering how can I launch the same activity as shown in the first example but also pass through the 'stationName' variable.
Any help would be greatly appreciated.
Cheers