Hi All,
I have developed an app widget, on which i am displaying "text" which
i am getting from network.
I have set update time daily as android:updatePeriodMillis="86400000",
my widget is updating properly on 1.5 sdk but not updating on 1.6 and
2.1, below is my code, please update me where am worng,
My Menifest Entries Below
****************************************
<receiver android:name=".MainWidgetProvider" android:label="@string/
app_name">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" /
>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_provider"
/>
</receiver>
<activity android:name=".QuoteViewScreen">
<intent-filter>
<action
android:name="com.main.MainWidgetProvider.ACTION_WIDGET_CONFIGURE"/>
</intent-filter>
</activity>
<service android:name=".MainWidgetProvider$UpdateWidgetService"/>
*********************************************************
My Widget class where i am handling data
public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget";
private static String currentQuoteId="0";
private static String imei=null;
private static String quoteDirection="";
public static RemoteViews remoteViews;
@Override
public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds) {
context.startService(new Intent(context,
UpdateWidgetService.class));
remoteViews = new RemoteViews(context.getPackageName(),
R.layout.widgetprovider_screen);
Intent mainQuoteViewIntent = new Intent(context,
QuoteViewScreen.class);
mainQuoteViewIntent.setAction(ACTION_WIDGET_CONFIGURE);
PendingIntent mainQuoteViewPendingIntent =
PendingIntent.getActivity(context, 0, mainQuoteViewIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.widget_layout,
mainQuoteViewPendingIntent);
remoteViews.setOnClickPendingIntent(R.id.widget_logo,
mainQuoteViewPendingIntent);
remoteViews.setOnClickPendingIntent(R.id.widgetquote_textview,
mainQuoteViewPendingIntent);
remoteViews.setOnClickPendingIntent(R.id.seperator_line,
mainQuoteViewPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
}
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}
public static class UpdateWidgetService extends IntentService {
QuoteObject quoteObject;
public UpdateWidgetService() {
super("MainWidgetProvider$UpdateWidgetService");
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onHandleIntent(Intent intent) {
ComponentName me = new ComponentName(this,
MainWidgetProvider.class);
AppWidgetManager mgr =
AppWidgetManager.getInstance(this);
mgr.updateAppWidget(me, updateWidget(this));
}
private RemoteViews updateWidget(Context context) {
imei = CQuoteUtility.getPhoneIMEI(context);
quoteObject = new QuoteObject();
getQuoteFromServer();
remoteViews.setTextViewText(R.id.widgetquote_textview,
"\""+quoteObject.getQuoteText()+"\" "+quoteObject.getQuoteAuthor());
setQuoteRatings(remoteViews,
quoteObject.getQuoteRating());
currentQuoteId = quoteObject.getQid();
return(remoteViews);
}
}
}
Why its not updating on 1.6 and 2.1 but working fine on 1.5.
One more thing how can i set the time from out side this XML file
<appwidget-provider />. means how to set the time from setting as
updating time will be "hourly", daily,
user can select any one from a UI,??????
Thanks in advance,
Gulfam
--
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