0

I'm trying to pass a string value from a widget configuration class to appWidgetProvider class. I've read that you pass a string between classes like this:

In current activity, create an intent

Intent i = new Intent(getApplicationContext(), ActivityB.class);
i.putExtra(key, value);
startActivity(i);

then in the other activity, retrieve those values.

Bundle extras = getIntent().getExtras(); 
if(extras !=null) {
    String value = extras.getString(key);
}

(for the "key" I declared a string)

but when writing the retrieve code into my appWidget provider is gives me an error saying: The method getIntent() is undefined for the type Widget

what do I do?

thanks very much

Jakob Harteg
  • 9,587
  • 15
  • 56
  • 78

1 Answers1

0

I guess that your Widget class is the app widget provider class. You can't call getIntent() here because getIntent() is a method of the Activity class

But I don't understand - how/why are you calling the app widget provider from your configuration activity? Intents the AppWidgetProvider class receives are created by the Android framework, not by you.

Jong
  • 9,045
  • 3
  • 34
  • 66
  • Well I'm new to programming, so I don't know what's going on at all times. But how ells can I get the value of a string in widget class which is set in my config class – Jakob Harteg Nov 23 '12 at 11:50
  • You shouldn't. Instead, you perform any configuration required for the app widget **inside** the app widget configuration activity, then update it. Read more here: http://developer.android.com/guide/topics/appwidgets/index.html#Configuring – Jong Nov 23 '12 at 15:06
  • yes I am doing that, I'm just having trouble updating it, so I thought I'd try something ells. Look at this question: http://stackoverflow.com/questions/13483131/update-textview-text-size-on-appwidget – Jakob Harteg Nov 23 '12 at 15:58