*Getting a String to AppWidget via GetExtras (or) Shared prefrences:*
I have an app widged which basically has a textview. I also have an activity
which displays a textview from string created within. Now i have a button in
Activity 1 which onClick will send data (string to appWidget class) I tried
putExtra and getExtra methods and also Shared preferences method, im little
confused to use which first!
Here are some inputs from me for more clarity.
Activity1:
*final String addwidget =
((TextView)findViewById(R.id.verse)).getText().toString();
Intent widgetIntent = new Intent(MyScheduledActivity.this,
MainWidget.class);
widgetIntent.putExtra("widgetVerse", addwidget);*
AppWidget:
*public class MainWidget extends AppWidgetProvider {
RemoteViews views;
public static String verseFromFav;
private Bundle getVerseData;
@Override
public void onReceive(Context context, Intent intent) {
getVerseData = intent.getExtras();
verseFromFav = getVerseData.getString("widgetVerse");
super.onReceive(context, intent);
}
@Override
public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
for (int i=0; i<N; i++) {
views = new
RemoteViews(context.getPackageName(),R.layout.widget_layout);
if(verseFromFav == null){
verseFromFav = "no verse";
}
views.setTextViewText(R.id.widgetVerse, verseFromFav);
ComponentName thisWidget = new ComponentName( context,
MainWidget.class );
AppWidgetManager.getInstance( context ).updateAppWidget(
thisWidget, views );
appWidgetManager.updateAppWidget(appWidgetIds, views);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}*
*}*
My StackOverflow question:
http://stackoverflow.com/questions/7560265/getting-a-string-to-appwidget-via-getextras-or-shared-prefrences/7560447#7560447
Please help me, im searching a lot for this but couldnt find much on sharing
to appWidget, any hints or help please.
--
Thank you,
Best Regards
Wesley
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en