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


Java Intent.setSourceBounds方法代码示例

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


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

示例1: onClickWallpaperPicker

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Event handler for the wallpaper picker button that appears after a long press
 * on the home screen.
 */
public void onClickWallpaperPicker(View v) {
    if (!Utilities.isWallapaperAllowed(this)) {
        Toast.makeText(this, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
        return;
    }

    /*String pickerPackage = getString(R.string.wallpaper_picker_package);
    if (TextUtils.isEmpty(pickerPackage)) {
        pickerPackage =  PackageManagerHelper.getWallpaperPickerPackage(getPackageManager());
    }*/

    int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
    float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);

    setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
    Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
            //.setPackage(pickerPackage)
            .putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);
    intent.setSourceBounds(getViewBounds(v));
    startActivityForResult(intent, REQUEST_PICK_WALLPAPER, getActivityLaunchOptions(v));
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:26,代码来源:Launcher.java

示例2: onClickWallpaperPicker

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Event handler for the wallpaper picker button that appears after a long press
 * on the home screen.
 */
public void onClickWallpaperPicker(View v) {
    if (!Utilities.isWallapaperAllowed(this)) {
        Toast.makeText(this, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
        return;
    }

    String pickerPackage = getString(R.string.wallpaper_picker_package);
    if (TextUtils.isEmpty(pickerPackage)) {
        pickerPackage =  PackageManagerHelper.getWallpaperPickerPackage(getPackageManager());
    }

    int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
    float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);

    setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
    Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
            .setPackage(pickerPackage)
            .putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);
    intent.setSourceBounds(getViewBounds(v));
    startActivityForResult(intent, REQUEST_PICK_WALLPAPER, getActivityLaunchOptions(v));
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:26,代码来源:Launcher.java

示例3: onClickWallpaperPicker

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Event handler for the wallpaper picker button that appears after a long press
 * on the home screen.
 */
public void onClickWallpaperPicker(View v) {
    if (!Utilities.isWallpaperAllowed(this)) {
        Toast.makeText(this, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
        return;
    }

    int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
    float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);
    setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
    Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
            .putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);

    String pickerPackage = getString(R.string.wallpaper_picker_package);
    boolean hasTargetPackage = TextUtils.isEmpty(pickerPackage);
    if (!hasTargetPackage) {
        intent.setPackage(pickerPackage);
    }

    intent.setSourceBounds(getViewBounds(v));
    try {
        startActivityForResult(intent, REQUEST_PICK_WALLPAPER,
                // If there is no target package, use the default intent chooser animation
                hasTargetPackage ? getActivityLaunchOptions(v) : null);
    } catch (ActivityNotFoundException e) {
        setWaitingForResult(null);
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:33,代码来源:Launcher.java

示例4: onClickSettingsButton

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Event handler for a click on the settings button that appears after a long press
 * on the home screen.
 */
public void onClickSettingsButton(View v) {
    Intent intent = new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
            .setPackage(getPackageName());
    intent.setSourceBounds(getViewBounds(v));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent, getActivityLaunchOptions(v));
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:12,代码来源:Launcher.java

示例5: startActivitySafely

import android.content.Intent; //导入方法依赖的package包/类
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
    if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    // Only launch using the new animation if the shortcut has not opted out (this is a
    // private contract between launcher and may be ignored in the future).
    boolean useLaunchAnimation = (v != null) &&
            !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
    Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;

    UserHandle user = item == null ? null : item.user;

    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(getViewBounds(v));
    }
    try {
        if (AndroidVersion.isAtLeastMarshmallow
                && (item instanceof ShortcutInfo)
                && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
                 || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
                && !((ShortcutInfo) item).isPromise()) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(Process.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            LauncherAppsCompat.getInstance(this).startActivityForProfile(
                    intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        return true;
    } catch (ActivityNotFoundException|SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:41,代码来源:Launcher.java

示例6: shortcutExists

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Returns true if the shortcuts already exists on the workspace. This must be called after
 * the workspace has been loaded. We identify a shortcut by its intent.
 */
private boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandle user) {
    final String intentWithPkg, intentWithoutPkg;
    if (intent == null) {
        // Skip items with null intents
        return true;
    }
    if (intent.getComponent() != null) {
        // If component is not null, an intent with null package will produce
        // the same result and should also be a match.
        String packageName = intent.getComponent().getPackageName();
        if (intent.getPackage() != null) {
            intentWithPkg = intent.toUri(0);
            intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
        } else {
            intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
            intentWithoutPkg = intent.toUri(0);
        }
    } else {
        intentWithPkg = intent.toUri(0);
        intentWithoutPkg = intent.toUri(0);
    }

    synchronized (dataModel) {
        for (ItemInfo item : dataModel.itemsIdMap) {
            if (item instanceof ShortcutInfo) {
                ShortcutInfo info = (ShortcutInfo) item;
                if (item.getIntent() != null && info.user.equals(user)) {
                    Intent copyIntent = new Intent(item.getIntent());
                    copyIntent.setSourceBounds(intent.getSourceBounds());
                    String s = copyIntent.toUri(0);
                    if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:44,代码来源:AddWorkspaceItemsTask.java

示例7: launchApp

import android.content.Intent; //导入方法依赖的package包/类
public static void launchApp(View view, Intent intent) {
    if (intent == null) {
        return;
    }

    intent.setSourceBounds(IntentUtil.getViewBounds(view));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    view.getContext().startActivity(intent, IntentUtil.getActivityLaunchOptions(view));
}
 
开发者ID:OhMyLob,项目名称:Paper-Launcher,代码行数:10,代码来源:IntentUtil.java

示例8: startGoogleSearchActivity

import android.content.Intent; //导入方法依赖的package包/类
public static void startGoogleSearchActivity(View view) {
    final Context context = view.getContext();

    final SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    if (searchManager == null) {
        return;
    }

    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    if (globalSearchActivity == null) {
        return;
    }

    Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(globalSearchActivity);

    Bundle appSearchData = new Bundle();
    appSearchData.putString("source", context.getPackageName());

    intent.putExtra(SearchManager.APP_DATA, appSearchData);
    intent.setSourceBounds(getViewBounds(view));
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:OhMyLob,项目名称:Paper-Launcher,代码行数:30,代码来源:IntentUtil.java

示例9: onClickSettingsButton

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Event handler for a click on the settings button that appears after a long press
 * on the home screen.
 */
public void onClickSettingsButton(View v) {
    if (LOGD) Log.d(TAG, "onClickSettingsButton");
    Intent intent = new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
            .setPackage(getPackageName());
    intent.setSourceBounds(getViewBounds(v));
    startActivity(intent, getActivityLaunchOptions(v));
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:12,代码来源:Launcher.java

示例10: startActivityForProfile

import android.content.Intent; //导入方法依赖的package包/类
public void startActivityForProfile(ComponentName component, UserHandleCompat user,
        Rect sourceBounds, Bundle opts) {
    Intent launchIntent = new Intent(Intent.ACTION_MAIN);
    launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    launchIntent.setComponent(component);
    launchIntent.setSourceBounds(sourceBounds);
    launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(launchIntent, opts);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:10,代码来源:LauncherAppsCompatV16.java

示例11: startShortcut

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void startShortcut(String packageName, String shortcutId, Rect sourceBounds, Bundle startActivityOptions, UserHandle user) {
    if (!mEnableBackport) return;
        ShortcutInfoCompat info = getShortcutCache().getShortcut(packageName, shortcutId);
        Intent intent = info.makeIntent(mContext);
        intent.setSourceBounds(sourceBounds);
        mContext.startActivity(intent);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:DeepShortcutManagerPreN.java

示例12: shortcutExists

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Returns true if the shortcuts already exists on the workspace. This must be called after
 * the workspace has been loaded. We identify a shortcut by its intent.
 */
@Thunk boolean shortcutExists(Context context, Intent intent, UserHandleCompat user) {
    assertWorkspaceLoaded();
    final String intentWithPkg, intentWithoutPkg;
    if (intent.getComponent() != null) {
        // If component is not null, an intent with null package will produce
        // the same result and should also be a match.
        String packageName = intent.getComponent().getPackageName();
        if (intent.getPackage() != null) {
            intentWithPkg = intent.toUri(0);
            intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
        } else {
            intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
            intentWithoutPkg = intent.toUri(0);
        }
    } else {
        intentWithPkg = intent.toUri(0);
        intentWithoutPkg = intent.toUri(0);
    }

    synchronized (sBgLock) {
        for (ItemInfo item : sBgItemsIdMap) {
            if (item instanceof ShortcutInfo) {
                ShortcutInfo info = (ShortcutInfo) item;
                Intent targetIntent = info.promisedIntent == null
                        ? info.intent : info.promisedIntent;
                if (targetIntent != null && info.user.equals(user)) {
                    Intent copyIntent = new Intent(targetIntent);
                    copyIntent.setSourceBounds(intent.getSourceBounds());
                    String s = copyIntent.toUri(0);
                    if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:43,代码来源:LauncherModel.java

示例13: startGoogleVoiceRecognitionActivity

import android.content.Intent; //导入方法依赖的package包/类
public static void startGoogleVoiceRecognitionActivity(View view) {
    Intent intent = new Intent("android.speech.action.VOICE_SEARCH_HANDS_FREE");
    intent.setSourceBounds(getViewBounds(view));
    view.getContext().startActivity(intent);
}
 
开发者ID:OhMyLob,项目名称:Paper-Launcher,代码行数:6,代码来源:IntentUtil.java

示例14: startActivitySafely

import android.content.Intent; //导入方法依赖的package包/类
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
    if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    // Only launch using the new animation if the shortcut has not opted out (this is a
    // private contract between launcher and may be ignored in the future).
    boolean useLaunchAnimation = (v != null) &&
            !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
    Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;

    UserHandleCompat user = null;
    if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) {
        long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1);
        user = UserManagerCompat.getInstance(this).getUserForSerialNumber(serialNumber);
    }

    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(getViewBounds(v));
    }
    try {
        if (Utilities.ATLEAST_MARSHMALLOW && item != null
                && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
                || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
                && ((ShortcutInfo) item).promisedIntent == null) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(UserHandleCompat.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            LauncherAppsCompat.getInstance(this).startActivityForProfile(
                    intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        return true;
    } catch (ActivityNotFoundException|SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e);
    }
    return false;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:44,代码来源:Launcher.java

示例15: startActivitySafely

import android.content.Intent; //导入方法依赖的package包/类
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
    if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    // Only launch using the new animation if the shortcut has not opted out (this is a
    // private contract between launcher and may be ignored in the future).
    boolean useLaunchAnimation = (v != null) &&
            !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
    Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;

    UserHandleCompat user = null;
    if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) {
        long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1);
        user = UserManagerCompat.getInstance(this).getUserForSerialNumber(serialNumber);
    }

    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(getViewBounds(v));
    }
    try {
        if (Utilities.ATLEAST_MARSHMALLOW && item != null
                && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
                || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
                && ((ShortcutInfo) item).promisedIntent == null) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(UserHandleCompat.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
            if (isAllAppsVisible()) {
                predictiveAppsProvider.updateComponentCount(intent.getComponent());
            }
        } else {
            LauncherAppsCompat.getInstance(this).startActivityForProfile(
                    intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        return true;
    } catch (ActivityNotFoundException|SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e);
    }
    return false;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:47,代码来源:Launcher.java


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