當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。