0

I'm working on an appWidget which has a textView, all i want is preview this textView in a new activity that i launch with

Intent configIntent = new Intent(context, ViewFromWidget.class);
configIntent.setAction(ACTION_WIDGET_CONFIGURE);
PendingIntent myPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);   
remoteViews.setOnClickPendingIntent(R.id.widgetLayout, myPendingIntent);

Can some one point me out on how can i send a string to the new activity that u start via appWidget?

Wesley
  • 1,808
  • 5
  • 31
  • 46

1 Answers1

0

That should be easy, you want to use an intent extra for passing strings.

Add this before setAction

   configIntent.putExtra("MyKey", myString);

And in the activity getting the intent use getStringExtra

   String passedString = getIntent().getStringExtra("MyKey");
Bobbake4
  • 24,509
  • 9
  • 59
  • 94
  • I actually tried that, but the new activity displays nothing,! am i missing something friend? – Wesley Oct 20 '11 at 21:31
  • 1
    You might want to have a look at this post http://stackoverflow.com/questions/4340431/how-can-i-correctly-pass-unique-extras-to-a-pending-intent. This might be an issue with the extras not being properly set on a pending intent. – Bobbake4 Oct 20 '11 at 21:40
  • 3
    Awesome! `PendingIntent.FLAG_UPDATE_CURRENT` did the job... Thanks for your help... – Wesley Oct 21 '11 at 06:52
  • @Wesley PendingIntent.FLAG_UPDATE_CURRENT fixed it for me! Thanks a lot, i spend few hours trying to figure out why it wasnt working! – Nabdreas Dec 24 '14 at 10:39