Hi, 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);
        }
}

(THE APP WIDGET SHOWS "no verse"  WHICH READS NULL)
Can any one help me with a basic idea on how to display the string
here. please. thanks in advance.

-- 
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

Reply via email to