当前位置: 首页>>代码示例>>Java>>正文


Java AppWidgetManager.getAppWidgetInfo方法代码示例

本文整理汇总了Java中android.appwidget.AppWidgetManager.getAppWidgetInfo方法的典型用法代码示例。如果您正苦于以下问题:Java AppWidgetManager.getAppWidgetInfo方法的具体用法?Java AppWidgetManager.getAppWidgetInfo怎么用?Java AppWidgetManager.getAppWidgetInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.appwidget.AppWidgetManager的用法示例。


在下文中一共展示了AppWidgetManager.getAppWidgetInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateWidgets

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private static void updateWidgets(Context context, AppWidgetManager manager, int[] appWidgetIds, boolean nextAccount) {
    Log.d("FinancistoWidget", "updateWidgets " + Arrays.toString(appWidgetIds) + " -> " + nextAccount);
    for (int id : appWidgetIds) {
        AppWidgetProviderInfo appWidgetInfo = manager.getAppWidgetInfo(id);
        if (appWidgetInfo != null) {
            int layoutId = appWidgetInfo.initialLayout;
            if (MyPreferences.isWidgetEnabled(context)) {
                long accountId = loadAccountForWidget(context, id);
                Class providerClass = getProviderClass(appWidgetInfo);
                Log.d("FinancistoWidget", "using provider " + providerClass);
                RemoteViews remoteViews = nextAccount || accountId == -1
                        ? buildUpdateForNextAccount(context, id, layoutId, providerClass, accountId)
                        : buildUpdateForCurrentAccount(context, id, layoutId, providerClass, accountId);
                manager.updateAppWidget(id, remoteViews);
            } else {
                manager.updateAppWidget(id, noDataUpdate(context, layoutId));
            }
        }
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:21,代码来源:AccountWidget.java

示例2: restoreAppWidgetIds

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
/**
 * Updates the app widgets whose id has changed during the restore process.
 */
static void restoreAppWidgetIds(Context context, PendingResult asyncResult,
        int[] oldWidgetIds, int[] newWidgetIds) {
    final ContentResolver cr = context.getContentResolver();
    final AppWidgetManager widgets = AppWidgetManager.getInstance(context);
    AppWidgetHost appWidgetHost = new AppWidgetHost(context, Launcher.APPWIDGET_HOST_ID);

    for (int i = 0; i < oldWidgetIds.length; i++) {

        final AppWidgetProviderInfo provider = widgets.getAppWidgetInfo(newWidgetIds[i]);
        final int state;
        if (LauncherModel.isValidProvider(provider)) {
            // This will ensure that we show 'Click to setup' UI if required.
            state = LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
        } else {
            state = LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY;
        }

        String[] widgetIdParams = new String[] { Integer.toString(oldWidgetIds[i]) };
        int result = new ContentWriter(context, new ContentWriter.CommitParams(
                "appWidgetId=? and (restored & 1) = 1", widgetIdParams))
                .put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i])
                .put(LauncherSettings.Favorites.RESTORED, state)
                .commit();

        if (result == 0) {
            Cursor cursor = cr.query(Favorites.CONTENT_URI,
                    new String[] {Favorites.APPWIDGET_ID},
                    "appWidgetId=?", widgetIdParams, null);
            try {
                if (!cursor.moveToFirst()) {
                    // The widget no long exists.
                    appWidgetHost.deleteAppWidgetId(newWidgetIds[i]);
                }
            } finally {
                cursor.close();
            }
        }
    }

    LauncherAppState app = LauncherAppState.getInstanceNoCreate();
    if (app != null) {
        app.getModel().forceReload();
    }
    asyncResult.finish();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:49,代码来源:AppWidgetsRestoredReceiver.java

示例3: restoreAppWidgetIds

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
/**
 * Updates the app widgets whose id has changed during the restore process.
 */
static void restoreAppWidgetIds(Context context, int[] oldWidgetIds, int[] newWidgetIds) {
    final ContentResolver cr = context.getContentResolver();
    final AppWidgetManager widgets = AppWidgetManager.getInstance(context);
    AppWidgetHost appWidgetHost = new AppWidgetHost(context, Launcher.APPWIDGET_HOST_ID);

    for (int i = 0; i < oldWidgetIds.length; i++) {
        Log.i(TAG, "Widget state restore id " + oldWidgetIds[i] + " => " + newWidgetIds[i]);

        final AppWidgetProviderInfo provider = widgets.getAppWidgetInfo(newWidgetIds[i]);
        final int state;
        if (LauncherModel.isValidProvider(provider)) {
            // This will ensure that we show 'Click to setup' UI if required.
            state = LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
        } else {
            state = LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY;
        }

        ContentValues values = new ContentValues();
        values.put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]);
        values.put(LauncherSettings.Favorites.RESTORED, state);

        String[] widgetIdParams = new String[] { Integer.toString(oldWidgetIds[i]) };

        int result = cr.update(Favorites.CONTENT_URI, values,
                "appWidgetId=? and (restored & 1) = 1", widgetIdParams);
        if (result == 0) {
            Cursor cursor = cr.query(Favorites.CONTENT_URI,
                    new String[] {Favorites.APPWIDGET_ID},
                    "appWidgetId=?", widgetIdParams, null);
            try {
                if (!cursor.moveToFirst()) {
                    // The widget no long exists.
                    appWidgetHost.deleteAppWidgetId(newWidgetIds[i]);
                }
            } finally {
                cursor.close();
            }
        }
    }

    LauncherAppState app = LauncherAppState.getInstanceNoCreate();
    if (app != null) {
        app.reloadWorkspace();
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:49,代码来源:AppWidgetsRestoredReceiver.java


注:本文中的android.appwidget.AppWidgetManager.getAppWidgetInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。