本文整理汇总了Java中android.appwidget.AppWidgetProviderInfo类的典型用法代码示例。如果您正苦于以下问题:Java AppWidgetProviderInfo类的具体用法?Java AppWidgetProviderInfo怎么用?Java AppWidgetProviderInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AppWidgetProviderInfo类属于android.appwidget包,在下文中一共展示了AppWidgetProviderInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromProviderInfo
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
public static LauncherAppWidgetProviderInfo fromProviderInfo(Context context,
AppWidgetProviderInfo info) {
final LauncherAppWidgetProviderInfo launcherInfo;
if (info instanceof LauncherAppWidgetProviderInfo) {
launcherInfo = (LauncherAppWidgetProviderInfo) info;
} else {
// In lieu of a public super copy constructor, we first write the AppWidgetProviderInfo
// into a parcel, and then construct a new LauncherAppWidgetProvider info from the
// associated super parcel constructor. This allows us to copy non-public members without
// using reflection.
Parcel p = Parcel.obtain();
info.writeToParcel(p, 0);
p.setDataPosition(0);
launcherInfo = new LauncherAppWidgetProviderInfo(p);
p.recycle();
}
launcherInfo.initSpans(context);
return launcherInfo;
}
示例2: beginResizeIfPointInRegion
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
public boolean beginResizeIfPointInRegion(int x, int y) {
boolean horizontalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0;
boolean verticalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0;
mLeftBorderActive = (x < mTouchTargetWidth) && horizontalActive;
mRightBorderActive = (x > getWidth() - mTouchTargetWidth) && horizontalActive;
mTopBorderActive = (y < mTouchTargetWidth + mTopTouchRegionAdjustment) && verticalActive;
mBottomBorderActive = (y > getHeight() - mTouchTargetWidth + mBottomTouchRegionAdjustment)
&& verticalActive;
boolean anyBordersActive = mLeftBorderActive || mRightBorderActive
|| mTopBorderActive || mBottomBorderActive;
mBaselineWidth = getMeasuredWidth();
mBaselineHeight = getMeasuredHeight();
mBaselineX = getLeft();
mBaselineY = getTop();
if (anyBordersActive) {
mLeftHandle.setAlpha(mLeftBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
mRightHandle.setAlpha(mRightBorderActive ? 1.0f :DIMMED_HANDLE_ALPHA);
mTopHandle.setAlpha(mTopBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
mBottomHandle.setAlpha(mBottomBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
}
return anyBordersActive;
}
示例3: get
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
/**
* - * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
* - * provided by the same package which is set to be global search activity.
* - * If widgetCategory is not supported, or no such widget is found, returns the first widget
* - * provided by the package.
* -
*/
public static AppWidgetProviderInfo get(Context context) {
SearchManager searchManager =
(SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
ComponentName searchComponent = searchManager.getGlobalSearchActivity();
if (searchComponent == null) return null;
String providerPkg = searchComponent.getPackageName();
AppWidgetProviderInfo defaultWidgetForSearchPackage = null;
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
return info;
} else if (defaultWidgetForSearchPackage == null) {
defaultWidgetForSearchPackage = info;
}
}
}
return defaultWidgetForSearchPackage;
}
示例4: configureWidget
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
private AppWidgetHostView configureWidget(Intent data) {
// Get the selected widget information
Bundle extras = data.getExtras();
int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
if (appWidgetInfo.configure != null) {
// If the widget wants to be configured then start its configuration activity
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
intent.setComponent(appWidgetInfo.configure);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
mParent.startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
} else {
// Otherwise simply create it
return createWidget(data);
}
return null;
}
示例5: getComponentNameFromIntent
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
public ComponentName getComponentNameFromIntent(Intent data) {
if (data!=null) {
Bundle extras = data.getExtras();
if (extras!=null) {
int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
if (appWidgetId != -1) {
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
if (appWidgetInfo != null) {
return appWidgetInfo.provider;
}
}
}
}
return null;
}
示例6: getSearchWidgetProvider
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
/**
* Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
* provided by the same package which is set to be global search activity.
* If widgetCategory is not supported, or no such widget is found, returns the first widget
* provided by the package.
*/
public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) {
SearchManager searchManager =
(SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
ComponentName searchComponent = searchManager.getGlobalSearchActivity();
if (searchComponent == null) return null;
String providerPkg = searchComponent.getPackageName();
AppWidgetProviderInfo defaultWidgetForSearchPackage = null;
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
return info;
} else if (defaultWidgetForSearchPackage == null) {
defaultWidgetForSearchPackage = info;
}
}
}
return defaultWidgetForSearchPackage;
}
示例7: getAllProviders
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
@Override
public List<AppWidgetProviderInfo> getAllProviders(@Nullable PackageUserKey packageUser) {
if (packageUser == null) {
return super.getAllProviders(null);
}
return mAppWidgetManager.getInstalledProvidersForPackage(packageUser.mPackageName,
packageUser.mUser);
}
示例8: getAppWidgetProviderInfo
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
public AppWidgetProviderInfo getAppWidgetProviderInfo(Context context) {
try {
return (AppWidgetProviderInfo) mObject.getClass()
.getDeclaredMethod("getAppWidgetProviderInfo", Context.class)
.invoke(mObject, context);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例9: startConfigActivity
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
@Override
public void startConfigActivity(AppWidgetProviderInfo info, int widgetId, Activity activity,
AppWidgetHost host, int requestCode) {
try {
host.startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode, null);
} catch (ActivityNotFoundException | SecurityException e) {
Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
}
}
示例10: findProvider
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
@Override
public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandle user) {
for (AppWidgetProviderInfo info : mAppWidgetManager
.getInstalledProvidersForProfile(user)) {
if (info.provider.equals(provider)) {
return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
}
}
return null;
}
示例11: getAllProvidersMap
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
@Override
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
for (UserHandle user : mUserManager.getUserProfiles()) {
for (AppWidgetProviderInfo info :
mAppWidgetManager.getInstalledProvidersForProfile(user)) {
result.put(new ComponentKey(info.provider, user), info);
}
}
return result;
}
示例12: update
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
/**
* @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
* only widgets and shortcuts associated with the package/user are.
*/
public ArrayList<WidgetItem> update(Context context, @Nullable PackageUserKey packageUser) {
final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
try {
PackageManager pm = context.getPackageManager();
InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
// Widgets
AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);
for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders(packageUser)) {
widgetsAndShortcuts.add(new WidgetItem(LauncherAppWidgetProviderInfo
.fromProviderInfo(context, widgetInfo), pm, idp));
}
// Shortcuts
for (ShortcutConfigActivityInfo info : LauncherAppsCompat.getInstance(context)
.getCustomShortcutActivityList(packageUser)) {
widgetsAndShortcuts.add(new WidgetItem(info));
}
setWidgetsAndShortcuts(widgetsAndShortcuts, context, packageUser);
} catch (Exception e) {
if (Utilities.isBinderSizeError(e)) {
// the returned value may be incomplete and will not be refreshed until the next
// time Launcher starts.
// TODO: after figuring out a repro step, introduce a dirty bit to check when
// onResume is called to refresh the widget provider list.
} else {
throw e;
}
}
return widgetsAndShortcuts;
}
示例13: getAppWidgetInfo
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
@Override
public AppWidgetProviderInfo getAppWidgetInfo() {
AppWidgetProviderInfo info = super.getAppWidgetInfo();
if (info != null && !(info instanceof LauncherAppWidgetProviderInfo)) {
throw new IllegalStateException("Launcher widget must have"
+ " LauncherAppWidgetProviderInfo");
}
return info;
}
示例14: getAdvanceable
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
private Advanceable getAdvanceable() {
AppWidgetProviderInfo info = getAppWidgetInfo();
if (info == null || info.autoAdvanceViewId == NO_ID || !mIsAttachedToWindow) {
return null;
}
View v = findViewById(info.autoAdvanceViewId);
return (v instanceof Advanceable) ? (Advanceable) v : null;
}
示例15: getSupportedResizeActions
import android.appwidget.AppWidgetProviderInfo; //导入依赖的package包/类
private ArrayList<Integer> getSupportedResizeActions(View host, LauncherAppWidgetInfo info) {
ArrayList<Integer> actions = new ArrayList<>();
AppWidgetProviderInfo providerInfo = ((LauncherAppWidgetHostView) host).getAppWidgetInfo();
if (providerInfo == null) {
return actions;
}
CellLayout layout = (CellLayout) host.getParent().getParent();
if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) {
if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) ||
layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) {
actions.add(R.string.action_increase_width);
}
if (info.spanX > info.minSpanX && info.spanX > 1) {
actions.add(R.string.action_decrease_width);
}
}
if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0) {
if (layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1) ||
layout.isRegionVacant(info.cellX, info.cellY - 1, info.spanX, 1)) {
actions.add(R.string.action_increase_height);
}
if (info.spanY > info.minSpanY && info.spanY > 1) {
actions.add(R.string.action_decrease_height);
}
}
return actions;
}