本文整理了Java中android.appwidget.AppWidgetManager.bindAppWidgetIdIfAllowed()
方法的一些代码示例,展示了AppWidgetManager.bindAppWidgetIdIfAllowed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppWidgetManager.bindAppWidgetIdIfAllowed()
方法的具体详情如下:
包路径:android.appwidget.AppWidgetManager
类名称:AppWidgetManager
方法名:bindAppWidgetIdIfAllowed
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void bindAppWidgetIdIfAllowed_shouldRecordTheBinding() throws Exception {
ComponentName provider = new ComponentName("A", "B");
appWidgetManager.bindAppWidgetIdIfAllowed(789, provider);
assertArrayEquals(new int[]{789}, appWidgetManager.getAppWidgetIds(provider));
}
代码示例来源:origin: robolectric/robolectric
@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));
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider);
} else {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider, options);
}
}
代码示例来源:origin: fookwood/Launcher3
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
if (Utilities.ATLEAST_JB_MR1) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider, options);
} else {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider);
}
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider);
} else {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider, options);
}
}
代码示例来源:origin: klinker24/launcher3
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
if (Utilities.ATLEAST_JB_MR1) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider, options);
} else {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider);
}
}
代码示例来源:origin: fookwood/Launcher3
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(
appWidgetId, info.getProfile(), info.provider, options);
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(
appWidgetId, info.getProfile(), info.provider, options);
}
代码示例来源:origin: klinker24/launcher3
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(
appWidgetId, info.getProfile(), info.provider, options);
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(
appWidgetId, info.getProfile(), info.provider, options);
}
代码示例来源:origin: enricocid/LaunchEnr
@Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) {
return mAppWidgetManager.bindAppWidgetIdIfAllowed(
appWidgetId, info.getProfile(), info.provider, options);
}
代码示例来源:origin: quaap/LaunchTime
private boolean checkBindPermission(final Activity parent, final int appWidgetId, final AppWidgetProviderInfo appWidgetInfo) {
try {
boolean allowed_to_bind = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, appWidgetInfo.provider);
// Ask the user to allow this app to have access to their widgets
if (!allowed_to_bind) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Log.d(TAG, "asking for permission");
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, appWidgetInfo.provider);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE, appWidgetInfo.getProfile());
}
addEmptyData(intent);
parent.startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
}
}, 500);
return true;
}
} catch( Exception e) {
Log.e(TAG, e.getMessage(), e);
return false;
}
return false;
}
代码示例来源:origin: stackoverflow.com
success = manager.bindAppWidgetIdIfAllowed(id, provider.provider);
if (success) {
AppWidgetHostView hostView = host.createView(getActivity(), id, provider);
代码示例来源:origin: WeAreFairphone/FP2-Launcher
private boolean addAppWidget(SQLiteDatabase db, ContentValues values, ComponentName cn,
Bundle extras) {
boolean allocatedAppWidgets = false;
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
try {
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
values.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET);
values.put(Favorites.APPWIDGET_ID, appWidgetId);
values.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
values.put(Favorites._ID, generateNewItemId());
dbInsertAndCheck(this, db, TABLE_FAVORITES, null, values);
allocatedAppWidgets = true;
// TODO: need to check return value
appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn);
// Send a broadcast to configure the widget
if (extras != null && !extras.isEmpty()) {
Intent intent = new Intent(ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE);
intent.setComponent(cn);
intent.putExtras(extras);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
mContext.sendBroadcast(intent);
}
} catch (RuntimeException ex) {
Log.e(TAG, "Problem allocating appWidgetId", ex);
}
return allocatedAppWidgets;
}
代码示例来源:origin: clemensbartz/essential-launcher
/**
* Bind a widget for a provider.
* @param provider the provider component
* @param configure the configure component
*/
public void bindWidget(final ComponentName provider, final ComponentName configure) {
final int appWidgetId = appWidgetHost.allocateAppWidgetId();
if (appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, provider)) {
// Binding is allowed, go straight to configuring
configureWidget(appWidgetId, configure);
} else {
// Ask for permission
widgetConfigure = configure;
final Intent intent = IntentUtil.createWidgetBindIntent(provider, appWidgetId);
final Bundle options = new Bundle();
options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, frWidget.getMinimumWidth());
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, frWidget.getWidth());
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, frWidget.getMinimumHeight());
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, frWidget.getHeight());
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
}
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn)) {
Log.e(TAG, "Unable to bind app widget id " + cn);
mAppWidgetHost.deleteAppWidgetId(appWidgetId);
代码示例来源:origin: klinker24/launcher3
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn)) {
Log.e(TAG, "Unable to bind app widget id " + cn);
mAppWidgetHost.deleteAppWidgetId(appWidgetId);
代码示例来源:origin: enricocid/LaunchEnr
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn)) {
mAppWidgetHost.deleteAppWidgetId(appWidgetId);
return -1;
代码示例来源:origin: WeAreFairphone/FP2-Launcher
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {
return false;
代码示例来源:origin: fookwood/Launcher3
int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {
return false;
内容来源于网络,如有侵权,请联系作者删除!