I have an AppWidget
that interacts with two Activities
. First Activity
asks user to type in some text. Here's the code to start this Activity
from AppWidget
:
Intent promptIntent = new Intent(context,
TransparentPromptActivity.class);
promptIntent.putExtra("appwidget_id", appWidgetId);
promptIntent.putExtra("message", incomingMessage);
PendingIntent promptPendingIntent = PendingIntent.getActivity(
context, 0, promptIntent, 0);
views.setOnClickPendingIntent(R.id.app_widget_tv,
promptPendingIntent);
This Activity
sends the entered message back to the AppWidge
t which displays it. Then there's an Activity
that shares the message, and here's the code to start this Activity
:
Intent shareIntent = new Intent(context, MainActivity.class);
shareIntent.putExtra("message", incomingMessage);
PendingIntent sharePendingIntent = PendingIntent.getActivity(
context, 0, shareIntent, 0);
views.setOnClickPendingIntent(R.id.app_widget_btn_share,
sharePendingIntent);
As you can see, the message is stored in a local incomingMessage
variable. However, when the second Activity
is started, incomingMessage
is empty, means the Intent
contents are not updated when the variable value changes. How this effect can be achieved? Thanks in advance.