android.content.Intent.setSourceBounds()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(357)

本文整理了Java中android.content.Intent.setSourceBounds()方法的一些代码示例,展示了Intent.setSourceBounds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.setSourceBounds()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:setSourceBounds

Intent.setSourceBounds介绍

暂无

代码示例

代码示例来源:origin: Neamar/KISS

@Override
public void doLaunch(Context context, View v) {
  Intent viewContact = new Intent(Intent.ACTION_VIEW);
  viewContact.setData(Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI,
      String.valueOf(contactPojo.lookupKey)));
  if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    viewContact.setSourceBounds(v.getClipBounds());
  }
  viewContact.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  viewContact.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
  context.startActivity(viewContact);
}

代码示例来源:origin: Neamar/KISS

@Override
  public void doLaunch(Context context, View v) {
    Intent intent = new Intent(settingPojo.settingName);
    if (!settingPojo.packageName.isEmpty()) {
      intent.setClassName(settingPojo.packageName, settingPojo.settingName);
    }
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      intent.setSourceBounds(v.getClipBounds());
    }

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    try {
      context.startActivity(intent);
    }
    catch(ActivityNotFoundException e) {
      e.printStackTrace();
      Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show();
    }
  }
}

代码示例来源:origin: Neamar/KISS

@SuppressLint("MissingPermission")
@Override
public void doLaunch(Context context, View v) {
  Intent phone = new Intent(Intent.ACTION_CALL);
  phone.setData(Uri.parse("tel:" + Uri.encode(phonePojo.phone)));
  if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    phone.setSourceBounds(v.getClipBounds());
  }
  phone.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  // Make sure we have permission to call someone as this is considered a dangerous permission
  if (Permission.ensureCallPhonePermission(phone)) {
    context.startActivity(phone);
  }
}

代码示例来源:origin: Neamar/KISS

@Override
  public void doLaunch(Context context, View v) {
    try {
      if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
        assert launcher != null;
        launcher.startMainActivity(className, appPojo.userHandle.getRealHandle(), v.getClipBounds(), null);
      } else {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setComponent(className);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
          intent.setSourceBounds(v.getClipBounds());
        }

        context.startActivity(intent);
      }
    } catch (ActivityNotFoundException | NullPointerException e) {
      // Application was just removed?
      // (null pointer exception can be thrown on Lollipop+ when app is missing)
      Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show();
    }
  }
}

代码示例来源:origin: Neamar/KISS

@Override
protected void doLaunch(Context context, View v) {
  if (shortcutPojo.isOreoShortcut()) {
    // Oreo shortcuts
    doOreoLaunch(context, v);
  } else {
    // Pre-oreo shortcuts
    try {
      Intent intent = Intent.parseUri(shortcutPojo.intentUri, 0);
      if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        intent.setSourceBounds(v.getClipBounds());
      }
      context.startActivity(intent);
    } catch (Exception e) {
      // Application was just removed?
      Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show();
    }
  }
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: WeAreFairphone/FP2-Launcher

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);
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

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);
}

代码示例来源:origin: klinker24/launcher3

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);
}

代码示例来源:origin: fookwood/Launcher3

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);
}

代码示例来源:origin: OhMyLob/Paper-Launcher

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);
}

代码示例来源:origin: OhMyLob/Paper-Launcher

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));
}

代码示例来源:origin: zhangke3016/TranslationCompat

public final void startActivity(Activity activity,Intent intent, View view, int nextShowViewId){
   mFirstActivity = activity;
   mFirstView =view;
   //rect 来存储共享元素位置信息
  Rect rect = new Rect();
  // 获取元素位置信息
  view.getGlobalVisibleRect(rect);
  // 将位置信息附加到 intent 上
  intent.setSourceBounds(rect);
  intent.putExtra(TRANSITION_NEXT_ID, nextShowViewId);
   nResId = nextShowViewId;
  activity.startActivity(intent);
  // 屏蔽 Activity 默认转场效果
  activity.overridePendingTransition(0,0);
}

代码示例来源:origin: fookwood/Launcher3

public void recordLaunch(View v, Intent intent, ShortcutInfo shortcut) {
    intent = new Intent(intent);
    intent.setSourceBounds(null);

    final String flat = intent.toUri(0);
    Intent broadcastIntent = new Intent(ACTION_LAUNCH).putExtra(EXTRA_INTENT, flat);
    if (shortcut != null) {
      broadcastIntent.putExtra(EXTRA_CONTAINER, shortcut.container)
          .putExtra(EXTRA_SCREEN, shortcut.screenId)
          .putExtra(EXTRA_CELLX, shortcut.cellX)
          .putExtra(EXTRA_CELLY, shortcut.cellY);
    }

    Bundle sourceExtras = LaunchSourceUtils.createSourceData();
    LaunchSourceUtils.populateSourceDataFromAncestorProvider(v, sourceExtras);
    broadcastIntent.putExtra(EXTRA_SOURCE, sourceExtras);
    mLauncher.sendBroadcast(broadcastIntent, mLaunchBroadcastPermission);
  }
}

代码示例来源:origin: OhMyLob/Paper-Launcher

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();
  }
}

代码示例来源:origin: enricocid/LaunchEnr

/**
 * 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));
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

/**
 * 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));
  startActivityForResult(intent, SettingsActivity.REQUEST, getActivityLaunchOptions(v));
}

代码示例来源:origin: wl9739/UITransitionDemo

public void imageClick(View view) {
  Intent intent = new Intent(AnimeActivity.this, AnimeDetailActivity.class);
  // 创建一个 rect 对象来存储共享元素位置信息
  Rect rect = new Rect();
  // 获取元素位置信息
  view.getGlobalVisibleRect(rect);
  // 将位置信息附加到 intent 上
  intent.setSourceBounds(rect);
  CustomImage customImage = (CustomImage) view;
  intent.putExtra(AnimeDetailActivity.EXTRA_IMAGE, customImage.getImageId());
  startActivity(intent);
  // 屏蔽 Activity 默认转场效果
  overridePendingTransition(0, 0);
}

代码示例来源:origin: klinker24/launcher3

/**
 * 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));
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

/**
 * 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));
}

相关文章

Intent类方法