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


Java AppWidgetManager.getAppWidgetIds方法代码示例

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


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

示例1: hasInstances

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
/**
 * Check against {@link AppWidgetManager} if there are any instances of this
 * widget.
 */
protected boolean hasInstances(final Context context) {
    final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    final int[] mAppWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context,
            getClass()));
    return mAppWidgetIds.length > 0;
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:11,代码来源:BaseAppWidget.java

示例2: onReceive

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
    MonolithWidget.intent = intent;
    Log.d(TAG, "onReceive is called");
    if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(intent.getAction())) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
                new ComponentName(context, getClass()));
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.monolith_widget);
        appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);
    }

    if (intent.getAction().equals(ACTION_WIDGET_CLICK)) {
        Log.e(TAG, "onReceive: Intent has ACTION_WIDGET_CLICK");
        Bundle bundle = new Bundle();
        bundle.putString(context.getResources().getString(R.string.title), intent.getStringExtra(context.getResources().getString(R.string.title)));
        bundle.putString(context.getResources().getString(R.string.date), intent.getStringExtra("date"));
        bundle.putString(context.getResources().getString(R.string.image), intent.getStringExtra("image"));
        bundle.putString(context.getResources().getString(R.string.description), intent.getStringExtra("description"));
        bundle.putString(context.getResources().getString(R.string.link), intent.getStringExtra(context.getResources().getString(R.string.link)));
        Intent intent1 = new Intent(context, ArticleDetailActivity.class);
        intent1.putExtras(bundle);
        intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent1);
    }
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:29,代码来源:MonolithWidget.java

示例3: updateUnreadCount

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
/**
 * Trigger update for all of our unread widgets.
 *
 * @param context
 *         The {@code Context} object to use for the broadcast intent.
 */
public static void updateUnreadCount(Context context) {
    Context appContext = context.getApplicationContext();
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(appContext);

    ComponentName thisWidget = new ComponentName(appContext, UnreadWidgetProvider.class);
    int[] widgetIds = appWidgetManager.getAppWidgetIds(thisWidget);

    Intent intent = new Intent(context, UnreadWidgetProvider.class);
    intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);

    context.sendBroadcast(intent);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:UnreadWidgetProvider.java

示例4: ComponentName

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void opdaterObservatører() {

    AppWidgetManager mAppWidgetManager = AppWidgetManager.getInstance(ApplicationSingleton.instans);
    int[] appWidgetId = mAppWidgetManager.getAppWidgetIds(new ComponentName(ApplicationSingleton.instans, AfspillerIkonOgNotifikation.class));

    for (int id : appWidgetId) {
      AfspillerIkonOgNotifikation.opdaterUdseende(ApplicationSingleton.instans, mAppWidgetManager, id);
    }

    // Notificér alle i observatørlisen - fra en kopi, sådan at de kan fjerne
    // sig selv fra listen uden at det giver ConcurrentModificationException
    for (Runnable observatør : new ArrayList<Runnable>(observatører)) {
      observatør.run();
    }
  }
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:16,代码来源:Afspiller.java

示例5: updateWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void updateWidget() {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, ClockWidget.class));
    if (appWidgetIds.length > 0) {
        new ClockWidget().onUpdate(this, appWidgetManager, appWidgetIds);
    }
}
 
开发者ID:WeAreFairphone,项目名称:android_packages_apps_ClockWidget,代码行数:8,代码来源:ClockScreenService.java

示例6: onReceive

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    DebugLog.logMethod();
    DebugLog.logMessage("Action: " + intent.getAction());
    super.onReceive(context, intent);
    if (!intent.getAction().equals(AppWidgetManager.ACTION_APPWIDGET_UPDATE)) {
        return;
    }

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
            new ComponentName(context, context.getPackageName()));
    onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:15,代码来源:CouponWidgetProvider.java

示例7: updateWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private void updateWidget() {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
    int appWidgetIds[] = appWidgetManager
            .getAppWidgetIds(new ComponentName(mContext, BuddyBookWidgetProvider.class));
    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);

}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:8,代码来源:BuddyBookWidgetService.java

示例8: removeOrphanedStates

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
/**
 *  Checks for any states that may have not received onDeleted.
 */
private void removeOrphanedStates(Context context) {
    AppWidgetManager wm = AppWidgetManager.getInstance(context);
    int[] ids = wm.getAppWidgetIds(getComponentName(context));
    for (int id : ids) {
        BookmarkWidgetService.deleteWidgetState(context, id);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:BookmarkWidgetProvider.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: _getIds

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
private int[] _getIds() {
    Context context = reactContext.getApplicationContext();

    AppWidgetManager man = AppWidgetManager.getInstance(context);
    return man.getAppWidgetIds(
            new ComponentName(context, this.widgetClass));
}
 
开发者ID:nightflash,项目名称:react-native-widget-manager,代码行数:8,代码来源:WidgetManagerModule.java

示例11: notifyChange

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
public void notifyChange(MusicXService musicXService, String what) {
    if (hasInstances(musicXService)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(musicXService);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(musicXService, this.getClass()));
        if (appWidgetIds.length > 0) {
            musicxWidgetUpdate(musicXService, appWidgetIds, what);
        }

    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:11,代码来源:MusicxWidget4x2.java

示例12: onConfigurationChanged

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
public void onConfigurationChanged(Configuration newConfig) {
    Log.d(TAG, "onConfigurationChanged() " + newConfig.toString());

    //Called when screen is rotated, phone charging state changes
    //The widget gets reset, so we need to reconfigure some things

    //Get AppWidgetManager
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext());

    // Get all widget ids
    int[] allWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(getApplication(), PingWidgetProvider.class));

    for (int widgetId : allWidgetIds) {

        //Get widget data
        PingWidgetData data = SharedPreferencesHelper.readPingWidgetData(getApplicationContext(), widgetId);
        if(data != null) {

            //Get RemoteViews
            RemoteViews views = RemoteViewsUtil.getRemoteViews(getApplicationContext(), data.getWidgetLayoutType());

            //Update widget views
            RemoteViewsUtil.initWidgetViews(getApplicationContext(), views, data);

            //Register an Intent so that onClicks on the widget are received by PingWidgetProvider.onReceive()
            //Create an Intent, set PING_WIDGET_TOGGLE action to it, put EXTRA_APPWIDGET_ID as extra
            Util.registerWidgetStartPauseOnClickListener(getApplication(), widgetId, views);
            Util.registerWidgetReconfigureClickListener(getApplication(), widgetId, views);

            //Update the widget
            appWidgetManager.updateAppWidget(widgetId, views);
        }

    }
    super.onConfigurationChanged(newConfig);
}
 
开发者ID:abicelis,项目名称:PingWidget,代码行数:38,代码来源:PingWidgetUpdateService.java

示例13: onReceive

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
/**
 * Receive broadcast for refresh
 *
 * @param context Application context
 * @param intent  Intent to do something
 */
@Override
public void onReceive(Context context, Intent intent) {

    String action = intent.getAction();
    if (action.equals(PRAYER_CHANGE) || action.equals(Intent.ACTION_DATE_CHANGED)) {
        AppWidgetManager gm = AppWidgetManager.getInstance(context);
        int[] ids = gm.getAppWidgetIds(new ComponentName(context, CalenderWidget.class));
        this.onUpdate(context, gm, ids);
    } else {
        super.onReceive(context, intent);
    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:19,代码来源:CalenderWidget.java

示例14: notifyWidget

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
public void notifyWidget(Recipe recipe) {
    AppWidgetManager widgetManager = AppWidgetManager.getInstance(this);

    int[] widgetsIds = widgetManager.getAppWidgetIds(new ComponentName(this, IngredientsWidgetProvider.class));
    IngredientsWidgetProvider.update(this, widgetManager, widgetsIds, recipe);

    Intent resultIntent = new Intent();
    resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    setResult(RESULT_OK, resultIntent);
    finish();
}
 
开发者ID:ecarrara-araujo,项目名称:yabaking,代码行数:12,代码来源:IngredientsWidgetProviderConfigurationActivity.java

示例15: onHandleIntent

import android.appwidget.AppWidgetManager; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(@Nullable Intent intent) {
    //Retrieve widget ids
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
    final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
            new ComponentName(this, PerformanceWidgetProvider.class));
    //Create a latch for synchronization
    final CountDownLatch latch = new CountDownLatch(1);

    context = getApplicationContext();

    //Get firebaseuid
    String firebaseUid = CacheUtils.getFirebaseUserId(context);

    //Get data from firebase
    FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
    statsDbRef = firebaseDatabase.getReference()
            .child("users").child(firebaseUid).child("stats");

    valueEventListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            stats = dataSnapshot.getValue(Stats.class);
            latch.countDown();
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            latch.countDown();
        }
    };
    statsDbRef.addListenerForSingleValueEvent(valueEventListener);

    try {

        //wait for firebase to download data
        latch.await();

        //check if download is successful
        if (stats != null) {
            final int todaysTotalSeconds = stats.getTodaysTotalSeconds();
            final int dailyAverage = stats.getDailyAverageSeconds();

            float progress;
            if (todaysTotalSeconds < dailyAverage) {
                progress = (todaysTotalSeconds / (float) dailyAverage) * 100f;
            } else {
                progress = 100f;
            }
            progress = Math.round(progress * 100) / 100f;

            for (int appWidgetId : appWidgetIds) {
                RemoteViews views = new RemoteViews(getPackageName(), R.layout.performance_widget);

                views.setTextViewText(R.id.todays_activity,
                        getString(R.string.todays_total_log_time, FormatUtils.getFormattedTime(context, todaysTotalSeconds)));
                views.setTextViewText(R.id.daily_average_text,
                        getString(R.string.daily_average_format, FormatUtils.getFormattedTime(context, dailyAverage)));

                views.setProgressBar(R.id.performance_bar, 100, (int) progress, false);

                String progressCd = getString(R.string.progress_description, progress);
                views.setContentDescription(R.id.performance_bar, progressCd);

                // Create an Intent to launch NavigationDrawerActivity
                Intent launchIntent = new Intent(this, NavigationDrawerActivity.class);
                PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, launchIntent, 0);
                views.setOnClickPendingIntent(R.id.widget, pendingIntent);

                appWidgetManager.updateAppWidget(appWidgetId, views);
            }
        }

    } catch (InterruptedException e) {
        FirebaseCrash.report(e);
    }
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:78,代码来源:PerformanceWidgetIntentService.java


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