AppWidgetManager getAppWidgetIds - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AppWidgetManager getAppWidgetIds method.

This code example shows how to use the following methods:bindAppWidgetIdIfAllowed, getAppWidgetIds
  } 
 
  @Test 
  public void bindAppWidgetIdIfAllowed_shouldRecordTheBinding() throws Exception { 
    ComponentName provider = new ComponentName("A", "B");
    appWidgetManager.bindAppWidgetIdIfAllowed(789, provider);
    assertArrayEquals(new int[]{789}, appWidgetManager.getAppWidgetIds(provider));
  } 
 
  @Test 
  public void bindAppWidgetId_shouldRecordAppWidgetInfo() throws Exception { 
    ComponentName provider = new ComponentName("abc", "123");
    AppWidgetProviderInfo providerInfo = new AppWidgetProviderInfo();
    providerInfo.provider = provider;
    shadowAppWidgetManager.addInstalledProvider(providerInfo);
 
    appWidgetManager.bindAppWidgetIdIfAllowed(90210, provider);
 
    assertSame(providerInfo, appWidgetManager.getAppWidgetInfo(90210));
  } 
7
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
 
		Log.w(LOG, "onUpdate method called");
		// Get all ids 
		ComponentName thisWidget = new ComponentName(context,
				MyWidgetProvider.class); 
		int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
 
		// Build the intent to call the service 
		Intent intent = new Intent(context.getApplicationContext(),
				UpdateWidgetService.class); 
		intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
 
		// Update the widgets via the service 
		context.startService(intent);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
public class KarmaWidget extends AppWidgetProvider {
	 
	@Override 
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
		if (appWidgetIds == null) {
			appWidgetIds = appWidgetManager.getAppWidgetIds(
					new ComponentName(context, KarmaWidget.class));
		} 
 
		UpdateService.requestUpdate(appWidgetIds);
		context.startService(new Intent(context, UpdateService.class));
	} 
	 
	@Override 
	public void onDeleted(Context context, int[] appWidgetIds) {
		final int N = appWidgetIds.length;
		for (int i=0; i<N; i++) {
			KarmaWidgetConfigurationActivity.deleteUsername(context, appWidgetIds[i]);
		} 
	} 
6
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
		editor.commit();
 
	} 
	 
	public static int getWidgetsCount(Context cnt) {
		int[] appWidgetIds = AppWidgetManager.getInstance(cnt).getAppWidgetIds(new ComponentName(cnt, WidgetCounters4x1.class));
		return appWidgetIds.length;
	} 
	 
	/* 
    public static int getWidgetsCount(Context cnt) { 
    	SharedPreferences prefs = cnt.getSharedPreferences(PREF_GLOBALS, Context.MODE_PRIVATE); 
        if (prefs.contains(WIDGETS_COUNT)) { 
        	return prefs.getInt(WIDGETS_COUNT, 0); 
        } else { 
            Editor editor = prefs.edit(); 
           	editor.putInt(WIDGETS_COUNT, 0); 
            editor.commit(); 
        	return 0; 
        } 
6
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
 
		final int N = appWidgetIds.length;
		ComponentName thisWidget = new ComponentName(context,
				SimpleWidgetAppWidgetProvider.class); 
		int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
 
		// Build the intent to call the service 
		Intent intent = new Intent(context.getApplicationContext(),
				UpdateWidgetService.class); 
		intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
 
		// Update the widgets via the service 
		context.startService(intent);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
 
		Log.w(LOG, "onUpdate method called");
		// Get all ids 
		ComponentName thisWidget = new ComponentName(context,
				ExampleAppWidgetProvider.class); 
		int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
 
		// Build the intent to call the service 
		Intent intent = new Intent(context.getApplicationContext(),
				UpdateWidgetService.class); 
		intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
 
		// Update the widgets via the service 
		context.startService(intent);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
 
		Log.w(LOG, "onUpdate method called");
		// Get all ids 
		ComponentName thisWidget = new ComponentName(context,
				ExampleAppWidgetProvider1.class); 
		int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
 
		// Build the intent to call the service 
		Intent intent = new Intent(context.getApplicationContext(),
				UpdateWidgetService1.class); 
		intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
 
		// Update the widgets via the service 
		context.startService(intent);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
This code example shows how to use the following methods:getAppWidgetIds
    private PendingIntent getBroadcastIntent(Context context) {
        return PendingIntent.getBroadcast(context, 0, new Intent(context, Provider.class), 0);
    } 
     
    private static int[] getAppWidgetIds(Context context) {
        return AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, Provider.class));
    } 
     
    private static AlarmManager getAlarmManager(Context context) {
        return (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getAppWidgetIds
	 
		getWidgetManager().notifyAppWidgetViewDataChanged(ids, R.id.stack_view);
	} 
	 
	private int[] getWidgetIds() { 
        return getWidgetManager().getAppWidgetIds(getComponentName());
	} 
	 
	private AppWidgetManager getWidgetManager() {
        return AppWidgetManager.getInstance(this);
	} 
	 
	private ComponentName getComponentName() {
		return new ComponentName(getPackageName(), getWidgetClass().getName() );
	} 
 
	private void createWidget(int appWidgetId) {
		if(hasWidgetData()) { 
			updateRemoteView(getWidgetManager(), appWidgetId);
			return; 
5
CodeRank

Related AppWidgetManager getAppWidgetIds Questions & Answers:

Other AppWidgetManager getAppWidgetIds Examples

19:	    ComponentName thisWidget = new ComponentName(context,
20:	        MyWidgetProvider.class);
21:	    int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
22:	
23:	    // Build the intent to call the service

Read More

getAppWidgetIds Method Overview
Get the list of appWidgetIds that have been bound to the given AppWidget provider.
See Code Examples for other Android AppWidgetManager Methods: