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

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

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

Intent.resolveType介绍

暂无

代码示例

代码示例来源:origin: android-hacker/VirtualXposed

public Intent getLaunchIntent(String packageName, int userId) {
  VPackageManager pm = VPackageManager.get();
  Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
  intentToResolve.addCategory(Intent.CATEGORY_INFO);
  intentToResolve.setPackage(packageName);
  List<ResolveInfo> ris = pm.queryIntentActivities(intentToResolve, intentToResolve.resolveType(context), 0, userId);
  // Otherwise, try to find a main launcher activity.
  if (ris == null || ris.size() <= 0) {
    // reuse the intent instance
    intentToResolve.removeCategory(Intent.CATEGORY_INFO);
    intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
    intentToResolve.setPackage(packageName);
    ris = pm.queryIntentActivities(intentToResolve, intentToResolve.resolveType(context), 0, userId);
  }
  if (ris == null || ris.size() <= 0) {
    return null;
  }
  Intent intent = new Intent(intentToResolve);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.setClassName(ris.get(0).activityInfo.packageName,
      ris.get(0).activityInfo.name);
  return intent;
}

代码示例来源:origin: android-hacker/VirtualXposed

Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
  String mimeType = intent.resolveType(this);
  if (mimeType != null) {
    try {

代码示例来源:origin: bzsome/VirtualApp-x326

Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
  String mimeType = intent.resolveType(this);
  if (mimeType != null) {
    try {

代码示例来源:origin: limpoxe/Android-Plugin-Framework

/**
 * Test whether this filter matches the given <var>intent</var>.
 *
 * @param intent The Intent to compare against.
 * @param resolve If true, the intent's type will be resolved by calling
 *                Intent.resolveType(); otherwise a simple match against
 *                Intent.type will be performed.
 * @param logTag Tag to use in debugging messages.
 *
 * @return Returns either a valid match constant (a combination of
 * {@link #MATCH_CATEGORY_MASK} and {@link #MATCH_ADJUSTMENT_MASK}),
 * or one of the error codes {@link #NO_MATCH_TYPE} if the type didn't match,
 * {@link #NO_MATCH_DATA} if the scheme/path didn't match,
 * {@link #NO_MATCH_ACTION if the action didn't match, or
 * {@link #NO_MATCH_CATEGORY} if one or more categories didn't match.
 *
 * @return How well the filter matches.  Negative if it doesn't match,
 *         zero or positive positive value if it does with a higher
 *         value representing a better match.
 *
 * @see #match(String, String, String, android.net.Uri , Set, String)
 */
public final int match(ContentResolver resolver, Intent intent,
    boolean resolve, String logTag) {
  String type = resolve ? intent.resolveType(resolver) : intent.getType();
  return match(intent.getAction(), type, intent.getScheme(),
         intent.getData(), intent.getCategories());
}

代码示例来源:origin: darkskygit/VirtualApp

Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
  String mimeType = intent.resolveType(this);
  if (mimeType != null) {
    try {

代码示例来源:origin: grzegorznittner/chanu

public static int determineTypeBits(Context context, Intent intent) {
  int typeBits = 0;
  String type = intent.resolveType(context);
  if (MIME_TYPE_ALL.equals(type)) {
    typeBits = DataManager.INCLUDE_ALL;
  } else if (MIME_TYPE_IMAGE.equals(type) ||
      DIR_TYPE_IMAGE.equals(type)) {
    typeBits = DataManager.INCLUDE_IMAGE;
  } else if (MIME_TYPE_VIDEO.equals(type) ||
      DIR_TYPE_VIDEO.equals(type)) {
    typeBits = DataManager.INCLUDE_VIDEO;
  } else {
    typeBits = DataManager.INCLUDE_ALL;
  }
  if (intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false)) {
    typeBits |= DataManager.INCLUDE_LOCAL_ONLY;
  }
  return typeBits;
}

代码示例来源:origin: darkskygit/VirtualApp

public Intent getLaunchIntent(String packageName, int userId) {
  VPackageManager pm = VPackageManager.get();
  Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
  intentToResolve.addCategory(Intent.CATEGORY_INFO);
  intentToResolve.setPackage(packageName);
  List<ResolveInfo> ris = pm.queryIntentActivities(intentToResolve, intentToResolve.resolveType(context), 0, userId);
  // Otherwise, try to find a main launcher activity.
  if (ris == null || ris.size() <= 0) {
    // reuse the intent instance
    intentToResolve.removeCategory(Intent.CATEGORY_INFO);
    intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
    intentToResolve.setPackage(packageName);
    ris = pm.queryIntentActivities(intentToResolve, intentToResolve.resolveType(context), 0, userId);
  }
  if (ris == null || ris.size() <= 0) {
    return null;
  }
  Intent intent = new Intent(intentToResolve);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.setClassName(ris.get(0).activityInfo.packageName,
      ris.get(0).activityInfo.name);
  return intent;
}

代码示例来源:origin: bzsome/VirtualApp-x326

public Intent getLaunchIntent(String packageName, int userId) {
  VPackageManager pm = VPackageManager.get();
  Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
  intentToResolve.addCategory(Intent.CATEGORY_INFO);
  intentToResolve.setPackage(packageName);
  List<ResolveInfo> ris = pm.queryIntentActivities(intentToResolve, intentToResolve.resolveType(context), 0, userId);
  // Otherwise, try to find a main launcher activity.
  if (ris == null || ris.size() <= 0) {
    // reuse the intent instance
    intentToResolve.removeCategory(Intent.CATEGORY_INFO);
    intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
    intentToResolve.setPackage(packageName);
    ris = pm.queryIntentActivities(intentToResolve, intentToResolve.resolveType(context), 0, userId);
  }
  if (ris == null || ris.size() <= 0) {
    return null;
  }
  Intent intent = new Intent(intentToResolve);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.setClassName(ris.get(0).activityInfo.packageName,
      ris.get(0).activityInfo.name);
  return intent;
}

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

final String type = intent.resolveType(this);
if (Contacts.CONTENT_TYPE.equals(type)) {
  mMode = MODE_PICK_CONTACT;

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

newIntent.setDataAndType(uri, newIntent.resolveType(mContext));

代码示例来源:origin: ximsfei/Android-plugin-support

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ActivityResult execStartActivity(
    Context who, IBinder contextThread, IBinder token, Fragment target,
    Intent intent, int requestCode, Bundle options) {
  ActivityInfo ai = resolveActivity(intent, intent.resolveType(who), DynamicConstants.RESOLVE_ACTIVITY);
  if (ai != null) {
    intent.putExtra(DynamicConstants.DYNAMIC_ACTIVITY_FLAG, ai.name);
    intent.setClassName(DynamicActivityThread.getInstance().getHostPackageName(),
        DynamicConstants.STUB_DYNAMIC_ACTIVITY);
  }
  try {
    return (ActivityResult) mInstrumentationReflect.setMethod("execStartActivity",
        Context.class, IBinder.class, IBinder.class, Fragment.class, Intent.class,
        int.class, Bundle.class)
        .invoke(mBase, who, contextThread, token, target, intent, requestCode, options);
  } catch (Exception e) {
  }
  return null;
}

代码示例来源:origin: ximsfei/Android-plugin-support

public ActivityResult execStartActivity(Context who, IBinder contextThread, IBinder token, Activity target,
                    Intent intent, int requestCode, Bundle options) {
  ActivityInfo ai = resolveActivity(intent, intent.resolveType(who), DynamicConstants.RESOLVE_ACTIVITY);
  if (ai != null) {
    intent.putExtra(DynamicConstants.DYNAMIC_ACTIVITY_FLAG, ai.name);
    intent.setClassName(DynamicActivityThread.getInstance().getHostPackageName(),
        DynamicConstants.STUB_DYNAMIC_ACTIVITY);
  }
  try {
    return (ActivityResult) mInstrumentationReflect.setMethod("execStartActivity",
        Context.class, IBinder.class, IBinder.class, Activity.class, Intent.class, int.class, Bundle.class)
        .invoke(mBase, who, contextThread, token, target, intent, requestCode, options);
  } catch (Exception e) {
  }
  return null;
}

代码示例来源:origin: ximsfei/Android-plugin-support

public ActivityResult execStartActivity(
    Context who, IBinder contextThread, IBinder token, String target,
    Intent intent, int requestCode, Bundle options) {
  ActivityInfo ai = resolveActivity(intent, intent.resolveType(who), DynamicConstants.RESOLVE_ACTIVITY);
  if (ai != null) {
    intent.putExtra(DynamicConstants.DYNAMIC_ACTIVITY_FLAG, ai.name);
    intent.setClassName(DynamicActivityThread.getInstance().getHostPackageName(),
        DynamicConstants.STUB_DYNAMIC_ACTIVITY);
  }
  try {
    return (ActivityResult) mInstrumentationReflect.setMethod("execStartActivity",
        Context.class, IBinder.class, IBinder.class, String.class, Intent.class, int.class, Bundle.class)
        .invoke(mBase, who, contextThread, token, target, intent, requestCode, options);
  } catch (Exception e) {
  }
  return null;
}

代码示例来源:origin: ximsfei/Android-plugin-support

public ActivityResult execStartActivity(
    Context who, IBinder contextThread, IBinder token, Activity target,
    Intent intent, int requestCode, Bundle options, UserHandle user) {
  ActivityInfo ai = resolveActivity(intent, intent.resolveType(who), DynamicConstants.RESOLVE_ACTIVITY);
  if (ai != null) {
    intent.putExtra(DynamicConstants.DYNAMIC_ACTIVITY_FLAG, ai.name);
    intent.setClassName(DynamicActivityThread.getInstance().getHostPackageName(),
        DynamicConstants.STUB_DYNAMIC_ACTIVITY);
  }
  try {
    return (ActivityResult) mInstrumentationReflect.setMethod("execStartActivity",
        Context.class, IBinder.class, IBinder.class, Activity.class, Intent.class,
        int.class, Bundle.class, UserHandle.class)
        .invoke(mBase, who, contextThread, token, target, intent, requestCode, options, user);
  } catch (Exception e) {
  }
  return null;
}

代码示例来源:origin: Dawish/BriskTVLauncher

String mimeType = intent.resolveType(mContext);
if (mimeType != null) {
  try {

相关文章

微信公众号

最新文章

更多

Intent类方法