當前位置: 首頁>>代碼示例>>Java>>正文


Java AppWidgetManager.getInstance方法代碼示例

本文整理匯總了Java中android.appwidget.AppWidgetManager.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java AppWidgetManager.getInstance方法的具體用法?Java AppWidgetManager.getInstance怎麽用?Java AppWidgetManager.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.appwidget.AppWidgetManager的用法示例。


在下文中一共展示了AppWidgetManager.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onReceive

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    AppWidgetManager mgr = AppWidgetManager.getInstance(context);
    if (intent.getAction().equals(WIDGET_ACTION)) {
        int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID);
        int viewIndex = intent.getIntExtra(EXTRA_ITEM, 0);

        List<Hit> mWidgetItems = CanvasDownloadTable.getRows(context.getContentResolver().query(CanvasDownloadTable.CONTENT_URI, null, null, null, null), true);
        Intent intent_detail = new Intent(context, PicDetail.class);
        intent_detail.putExtra(PicDetail.EXTRA_PIC, mWidgetItems.get(viewIndex));
        intent_detail.putExtra(PicDetail.origin,context.getResources().getString(R.string.widget));
        intent_detail.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent_detail);
    }
    super.onReceive(context, intent);
}
 
開發者ID:MuditSrivastava,項目名稱:Canvas-Vision,代碼行數:18,代碼來源:StackWidgetProvider.java

示例2: onReceive

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(final Context context, Intent widgetIntent) {
    final String action = widgetIntent.getAction();

    if (REFRESH_ACTION.equals(action)) {
        LOGD(TAG, "received REFRESH_ACTION from widget");
        final boolean shouldSync = widgetIntent.getBooleanExtra(EXTRA_PERFORM_SYNC, false);

        // Trigger sync
        Account chosenAccount = AccountUtils.getActiveAccount(context);
        if (shouldSync && chosenAccount != null) {
            SyncHelper.requestManualSync(chosenAccount);
        }

        // Notify the widget that the list view needs to be updated.
        final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
        final ComponentName cn = new ComponentName(context, ScheduleWidgetProvider.class);
        mgr.notifyAppWidgetViewDataChanged(mgr.getAppWidgetIds(cn),
                R.id.widget_schedule_list);

    }
    super.onReceive(context, widgetIntent);
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:24,代碼來源:ScheduleWidgetProvider.java

示例3: pushUpdate

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void pushUpdate(Context context, int[] appWidgetIds, RemoteViews views) {
    // Update specific list of appWidgetIds if given, otherwise default to all
    final AppWidgetManager gm = AppWidgetManager.getInstance(context);
    if (appWidgetIds != null) {
        gm.updateAppWidget(appWidgetIds, views);
    } else {
        gm.updateAppWidget(new ComponentName(context, this.getClass()), views);
    }
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:10,代碼來源:MusicXwidget4x4.java

示例4: pushUpdate

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void pushUpdate(Context context, int[] appWidgetIds,
                        RemoteViews views) {
    // Update specific list of appWidgetIds if given, otherwise default to
    // all
    final AppWidgetManager gm = AppWidgetManager.getInstance(context);
    if (appWidgetIds != null) {
        gm.updateAppWidget(appWidgetIds, views);
    } else {
        gm.updateAppWidget(new ComponentName(context, this.getClass()),
                views);
    }
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:13,代碼來源:MediaAppWidgetProvider2x1.java

示例5: update

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
/**
 * Updates the AppWidget after the ImageView has loaded the Bitmap.
 */
private void update() {
  AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this.context);
  if (this.componentName != null) {
    appWidgetManager.updateAppWidget(this.componentName, this.remoteViews);
  } else {
    appWidgetManager.updateAppWidget(this.widgetIds, this.remoteViews);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:AppWidgetTarget.java

示例6: onReceive

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    if (intent.getAction().equals(ACTION_DATA_UPDATED)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
                new ComponentName(context, getClass()));
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);
    }
}
 
開發者ID:mvescovo,項目名稱:item-reaper,代碼行數:11,代碼來源:ItemWidgetProvider.java

示例7: updateWidget

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
public void updateWidget() {
    Intent intent = new Intent(this, BuddyBookWidgetProvider.class);
    intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    // Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID,
    // since it seems the onUpdate() is only fired on that:
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
    int appWidgetIds[] = appWidgetManager
            .getAppWidgetIds(new ComponentName(mContext, BuddyBookWidgetProvider.class));

    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);

    sendBroadcast(intent);
}
 
開發者ID:victoraldir,項目名稱:BuddyBook,代碼行數:14,代碼來源:MainActivity.java

示例8: pushUpdate

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void pushUpdate(final Context context, final int[] appWidgetIds, final RemoteViews views) {
    final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    if (appWidgetIds != null) {
        appWidgetManager.updateAppWidget(appWidgetIds, views);
    } else {
        appWidgetManager.updateAppWidget(new ComponentName(context, getClass()), views);
    }
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:9,代碼來源:AppWidgetBig.java

示例9: hasInstances

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
/**
 * Check against {@link AppWidgetManager} if there are any instances of this
 * widget.
 */
private boolean hasInstances(Context context) {
    AppWidgetManager appWidgetManager = AppWidgetManager
            .getInstance(context);
    int[] appWidgetIds = appWidgetManager
            .getAppWidgetIds(new ComponentName(context, this.getClass()));
    return (appWidgetIds.length > 0);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:12,代碼來源:MediaAppWidgetProvider4x2_Light.java

示例10: onReceive

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    int[] appWidgetIDs;
    if (intent.getAction().equals(ACTION_UPDATE)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        appWidgetIDs = appWidgetManager.getAppWidgetIds(new ComponentName(context, getClass()));
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIDs, R.id.newsList);
    }
}
 
開發者ID:vikasdesale,項目名稱:News24x7-news-from-every-part-of-the-world,代碼行數:11,代碼來源:NewsWidgetProvider.java

示例11: hasInstances

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private boolean hasInstances(Context context) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, this.getClass()));
    return (appWidgetIds.length > 0);
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:6,代碼來源:MusicXwidget4x4.java

示例12: PingAsyncTask

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
public PingAsyncTask(Context appContext, int widgetId) {

        mAppContext = appContext;
        mWidgetId = widgetId;
        mAppWidgetManager = AppWidgetManager.getInstance(appContext);
    }
 
開發者ID:abicelis,項目名稱:PingWidget,代碼行數:7,代碼來源:PingAsyncTask.java

示例13: AppWidgetManagerCompat

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
AppWidgetManagerCompat(Context context) {
    mContext = context;
    mAppWidgetManager = AppWidgetManager.getInstance(context);
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:5,代碼來源:AppWidgetManagerCompat.java

示例14: findAppWidgetIds

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private static int[] findAppWidgetIds(Context context) {
    AppWidgetManager manager = AppWidgetManager.getInstance(context);
    ComponentName widget = new ComponentName(context, RecordingWidgetProvider.class);
    return manager.getAppWidgetIds(widget);

}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:7,代碼來源:WidgetHelper.java

示例15: handleActionUpdateWidgets

import android.appwidget.AppWidgetManager; //導入方法依賴的package包/類
private void handleActionUpdateWidgets(Recipe recipe) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, RecipeWidgetProvider.class));
    RecipeWidgetProvider.updateRecipeWidgets(this, appWidgetManager, recipe, appWidgetIds);
}
 
開發者ID:twisstosin,項目名稱:UdacityBakingAndroid,代碼行數:6,代碼來源:RecipeWidgetService.java


注:本文中的android.appwidget.AppWidgetManager.getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。