开发学院手机开发Android 开发 Android实现widget定时更新 阅读

Android实现widget定时更新

 2010-06-19 17:37:00 来源:WEB开发网   
核心提示:return null;}public static void updateAppWidgetIds(int[] appWidgetIds){synchronized (sLock) {for (int appWidgetId : appWidgetIds) {sAppWidgetIds.add(appWidgetId

return null;

}

public static void updateAppWidgetIds(int[] appWidgetIds){

synchronized (sLock) {

for (int appWidgetId : appWidgetIds) {

sAppWidgetIds.add(appWidgetId);

}

}

}

public static int getNextWidgetId(){

synchronized (sLock) {

if (sAppWidgetIds.peek() == null) {

return AppWidgetManager.INVALID_APPWIDGET_ID;

} else {

return sAppWidgetIds.poll();

}

}

}

private static boolean hasMoreUpdates() {

synchronized (sLock) {

boolean hasMore = !sAppWidgetIds.isEmpty();

if (!hasMore) {

sThreadRunning = false;

}

return hasMore;

}

}

@Override

public void onCreate() {

super.onCreate();

}

@Override

public void onStart(Intent intent, int startId) {

super.onStart(intent, startId);

if (null != intent) {

if (ACTION_UPDATE_ALL.equals(intent.getAction())) {

AppWidgetManager widget = AppWidgetManager.getInstance(this);

updateAppWidgetIds(widget.getAppWidgetIds(new ComponentName(this, NewsWidgetProvider.class)));

}

}

synchronized (sLock) {

if (!sThreadRunning) {

sThreadRunning=true;

new Thread(this).start();

}

}

}

@Override

public void run() {

SharedPreferences setting=getSharedPreferences("com.xxxx.news_preferences", 0);

String updateTime=setting.getString("list_time", "1800000");

String updateUrl=setting.getString("list_site", "xxxxxxxxx");

AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(this);

RemoteViews updateViews=null;

while (hasMoreUpdates()) {

上一页  1 2 3 4 5 6  下一页

Tags:Android 实现 widget

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接