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


Java AppWidgetProvider类代码示例

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


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

示例1: updateAllWidgets

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
public static void updateAllWidgets(boolean SU_SEL, final Context context,
    final int layoutResourceId,
    final Class < ? extends AppWidgetProvider > appWidgetClass) {
    boolean su = SuBinary();
    boolean selinux = isSELinuxActive(context);
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), layoutResourceId);
    remoteViews.setTextViewText(R.id.iSuMain, "SU" + "\n" + (su ?
        context.getString(R.string.activated) : context.getString(R.string.deactivated)));
    remoteViews.setInt(R.id.iSuMain, "setBackgroundResource", (su ? R.drawable.button :
        R.drawable.buttong));
    if (SU_SEL) {
        remoteViews.setTextViewText(R.id.iSuMonitor, context.getString(R.string.selinux) + "\n" + (selinux ? context.getString(R.string.enforcing) :
            context.getString(R.string.permissive)));
        remoteViews.setInt(R.id.iSuMonitor, "setBackgroundResource", (selinux ? R.drawable.buttong :
            R.drawable.button));
    }
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, appWidgetClass));
    appWidgetManager.partiallyUpdateAppWidget(appWidgetIds, remoteViews);
}
 
开发者ID:bhb27,项目名称:isu,代码行数:21,代码来源:Tools.java

示例2: createWidgets

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
/**
 * Creates a bunch of widgets by inflating the same layout multiple times.
 *
 * @param appWidgetProviderClass the app widget provider class
 * @param widgetLayoutId         id of the layout to inflate
 * @param howManyToCreate        number of new widgets to create
 * @return the IDs of the new widgets
 */
public int[] createWidgets(Class<? extends AppWidgetProvider> appWidgetProviderClass, int widgetLayoutId, int howManyToCreate) {
  AppWidgetProvider appWidgetProvider = newInstanceOf(appWidgetProviderClass);

  int[] newWidgetIds = new int[howManyToCreate];
  for (int i = 0; i < howManyToCreate; i++) {
    View widgetView = createWidgetView(widgetLayoutId);

    int myWidgetId = nextWidgetId++;
    widgetInfos.put(myWidgetId, new WidgetInfo(widgetView, widgetLayoutId, appWidgetProvider));
    newWidgetIds[i] = myWidgetId;
  }

  appWidgetProvider.onUpdate(context, realAppWidgetManager, newWidgetIds);
  return newWidgetIds;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:24,代码来源:ShadowAppWidgetManager.java

示例3: getWidgetIDs

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
public void getWidgetIDs(){
    AppWidgetManager manager = AppWidgetManager.getInstance(this);
    ArrayList<Integer> widgets = new ArrayList<>();
    int[] IDs;

    IDs = manager.getAppWidgetIds(new ComponentName(getApplicationContext(), AppWidgetProvider.class));
    for(int i=0; i < IDs.length;i++){
        //Toast.makeText(getBaseContext(),"IDS: " + IDs[i] ,Toast.LENGTH_LONG).show();
        widgets.add(IDs[i]);
    }
}
 
开发者ID:ViWu,项目名称:Exo-Launcher,代码行数:12,代码来源:MainActivity.java

示例4: addListener

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
public static void addListener(Context context, RemoteViews rv, int appWidgetId, int componentId, String action, Class<? extends AppWidgetProvider> widgetClass) {
    Intent intent = new Intent(context, widgetClass)
            .setAction(action)
            .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT); // use the appWidgetId as a unique identifier to avoid different instances overwriting each other
    rv.setOnClickPendingIntent(componentId, pendingIntent);
}
 
开发者ID:rmnoon,项目名称:WorkflowyList,代码行数:8,代码来源:AppWidgetUtils.java

示例5: fireEvent

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
public static void fireEvent(Context context, int appWidgetId, String action, Class<? extends AppWidgetProvider> widgetClass, Map<String, String> extraStrings, Map<String, Integer> extraInts) {
    Intent intent = new Intent(context, widgetClass)
            .setAction(action)
            .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    fillIntent(intent, extraStrings, extraInts);
    context.sendBroadcast(intent);
}
 
开发者ID:rmnoon,项目名称:WorkflowyList,代码行数:8,代码来源:AppWidgetUtils.java

示例6: addListListener

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
public static void addListListener(Context context, RemoteViews rv, int appWidgetId, int componentId, String action, Class<? extends AppWidgetProvider> widgetClass) {
    // Here we setup the a pending intent template. Individuals items of a collection
    // cannot setup their own pending intents, instead, the collection as a whole can
    // setup a pending intent template, and the individual items can set a fillInIntent
    // to create unique before on an item to item basis.
    Intent i = new Intent(context, widgetClass)
                .setAction(action)
                .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    i.setData(Uri.parse(i.toUri(Intent.URI_INTENT_SCHEME)));
    PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
    rv.setPendingIntentTemplate(componentId, pi);
}
 
开发者ID:rmnoon,项目名称:WorkflowyList,代码行数:13,代码来源:AppWidgetUtils.java

示例7: updateWidgets

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
public static void updateWidgets(Context context, Class<? extends AppWidgetProvider> widgetType) {
    Intent intent = new Intent(context, widgetType);
    intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
    int ids[] = AppWidgetManager.getInstance(context)
            .getAppWidgetIds(new ComponentName(context, widgetType));
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,ids);
    context.sendBroadcast(intent);
}
 
开发者ID:Fleker,项目名称:CumulusTV,代码行数:9,代码来源:ChannelShortcut.java

示例8: WidgetInfo

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
public WidgetInfo(View view, int layoutId, AppWidgetProvider appWidgetProvider) {
  this.view = view;
  this.layoutId = layoutId;
  this.appWidgetProvider = appWidgetProvider;
  String packageName = appWidgetProvider.getClass().getPackage().getName();
  String className = appWidgetProvider.getClass().getName();
  providerComponent = new ComponentName(packageName, className);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:9,代码来源:ShadowAppWidgetManager.java

示例9: shouldNotComplainIfServiceIsDestroyedWhileAnotherServiceHasRegisteredBroadcastReceivers

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
@Test
public void shouldNotComplainIfServiceIsDestroyedWhileAnotherServiceHasRegisteredBroadcastReceivers()
  throws Exception {

  MyService service1 = new MyService();
  MyService service2 = new MyService();
  service2.registerReceiver(new AppWidgetProvider(), new IntentFilter());
  service1.onDestroy(); // should not throw exception
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:10,代码来源:ServiceTest.java

示例10: shouldNotComplainIfActivityIsDestroyedWhileAnotherActivityHasRegisteredBroadcastReceivers

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
@Test
public void shouldNotComplainIfActivityIsDestroyedWhileAnotherActivityHasRegisteredBroadcastReceivers() throws Exception {
  activity = create(DialogLifeCycleActivity.class);

  DialogLifeCycleActivity activity2 = new DialogLifeCycleActivity();
  activity2.registerReceiver(new AppWidgetProvider(), new IntentFilter());

  destroy(activity); // should not throw exception
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:10,代码来源:ActivityTest.java

示例11: pushUpdate

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
private void pushUpdate(Context context, int[] appWidgetIds, RemoteViews views) {
    // Update specific list of appWidgetIds if given,
    // otherwise default to all
    AppWidgetManager manager = AppWidgetManager.getInstance(context);
    if (appWidgetIds != null) {
        manager.updateAppWidget(appWidgetIds, views);
    } else {
        Class<? extends AppWidgetProvider> cls = getClass();
        ComponentName provider = new ComponentName(context, cls);
        manager.updateAppWidget(provider, views);
    }
}
 
开发者ID:ration,项目名称:android-vlc-remote,代码行数:13,代码来源:MediaAppWidgetProvider.java

示例12: provideAppWidgetProviderContext

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
/**
 * Provides the Context for the AppWidgetProvider associated with this graph.
 *
 * @return the AppWidgetProvider Context
 */
@Provides
@Singleton
@AppWidgetProvider
public Context provideAppWidgetProviderContext() {
    return mContext;
}
 
开发者ID:adennie,项目名称:fb-android-dagger,代码行数:12,代码来源:InjectingAppWidgetProvider.java

示例13: provideAppWidgetProviderInjector

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
/**
 * Provides the Injector for the AppWidgetProvider-scope graph
 *
 * @return the Injector
 */
@Provides
@Singleton
@AppWidgetProvider
public Injector provideAppWidgetProviderInjector() {
    return mInjector;
}
 
开发者ID:adennie,项目名称:fb-android-dagger,代码行数:12,代码来源:InjectingAppWidgetProvider.java

示例14: ForceUpdateAll

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
@SuppressWarnings("unused")
static public void ForceUpdateAll(Context ctx, Class<? extends AppWidgetProvider> widgetProviderClass) {
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(ctx);
    ComponentName thisAppWidget = new ComponentName(ctx.getPackageName(), widgetProviderClass.getName());

    @SuppressWarnings("ConstantConditions")
    int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);
    assert appWidgetIds != null;
    for (int id : appWidgetIds) {
        ForceUpdate(ctx, id, widgetProviderClass);
    }
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:13,代码来源:WidgetUpdateService.java

示例15: getAppWidgetProvider

import android.appwidget.AppWidgetProvider; //导入依赖的package包/类
private Class<? extends AppWidgetProvider> getAppWidgetProvider() {
	return NewsAppWidgetProvider.class;
}
 
开发者ID:benniaobuguai,项目名称:opencdk-appwidget,代码行数:4,代码来源:NewsRemoteViews.java


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