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


Java ResolveInfo类代码示例

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


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

示例1: grantPermissions

import android.content.pm.ResolveInfo; //导入依赖的package包/类
/**
 * 授权
 *
 * @param context
 * @param intent
 * @param uri
 * @param writeAble
 */
public static void grantPermissions(Context context, Intent intent, Uri uri, boolean writeAble) {

    int flag = Intent.FLAG_GRANT_READ_URI_PERMISSION;
    if (writeAble) {
        flag |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
    }
    intent.addFlags(flag);
    List<ResolveInfo> resInfoList = context.getPackageManager()
            .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo resolveInfo : resInfoList) {
        String packageName = resolveInfo.activityInfo.packageName;
        context.grantUriPermission(packageName, uri, flag);
    }
}
 
开发者ID:Jusenr,项目名称:AppFirCloud,代码行数:23,代码来源:FileProvider7.java

示例2: findProviders

import android.content.pm.ResolveInfo; //导入依赖的package包/类
/**
 * Resolves the {@link ComponentName components} for all providers which can handle the
 * specified OpenYOLO action.
 */
@NonNull
public static List<ComponentName> findProviders(
        @NonNull Context applicationContext,
        @NonNull String action) {
    Intent providerIntent = new Intent(action);
    providerIntent.addCategory(OPENYOLO_CATEGORY);

    List<ResolveInfo> resolveInfos =
            applicationContext.getPackageManager()
                    .queryIntentActivities(providerIntent, 0);

    ArrayList<ComponentName> responders = new ArrayList<>();
    for (ResolveInfo info : resolveInfos) {
        responders.add(new ComponentName(
                info.activityInfo.packageName,
                info.activityInfo.name));
    }

    return responders;
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:25,代码来源:ProviderResolver.java

示例3: getLaunchIntent

import android.content.pm.ResolveInfo; //导入依赖的package包/类
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;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:25,代码来源:VirtualCore.java

示例4: queryIntentForPackage

import android.content.pm.ResolveInfo; //导入依赖的package包/类
public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType, int flags,
		ArrayList<PackageParser.Service> packageServices) {
	if (packageServices == null) {
		return null;
	}
	mFlags = flags;
	final boolean defaultOnly = (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0;
	final int N = packageServices.size();
	ArrayList<PackageParser.ServiceIntentInfo[]> listCut = new ArrayList<PackageParser.ServiceIntentInfo[]>(N);

	ArrayList<PackageParser.ServiceIntentInfo> intentFilters;
	for (int i = 0; i < N; ++i) {
		intentFilters = packageServices.get(i).intents;
		if (intentFilters != null && intentFilters.size() > 0) {
			PackageParser.ServiceIntentInfo[] array = new PackageParser.ServiceIntentInfo[intentFilters.size()];
			intentFilters.toArray(array);
			listCut.add(array);
		}
	}
	return super.queryIntentFromList(intent, resolvedType, defaultOnly, listCut);
}
 
开发者ID:codehz,项目名称:container,代码行数:22,代码来源:VPackageManagerService.java

示例5: getIntentFromUri

import android.content.pm.ResolveInfo; //导入依赖的package包/类
/**
 * 从uri中解析出Intent
 *
 * @param context 上下文
 * @param uri     uri
 * @param flags   intentFlags
 *
 * @return Intent
 */
public static Intent getIntentFromUri(Context context, String uri, int flags) {
	try {
		Intent intent = Intent.parseUri(uri, flags);
		if (intent == null) {
			return null;
		}
		List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0);
		if (list == null || list.isEmpty()) {
			return null;
		}
		if (!(context instanceof Activity)) {
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		}
		return intent;
	} catch (Throwable e) {
		DLog.e(e);
	}
	return null;
}
 
开发者ID:youmi,项目名称:nativead,代码行数:29,代码来源:IntentUtils.java

示例6: newResult

import android.content.pm.ResolveInfo; //导入依赖的package包/类
@Override
protected ResolveInfo newResult(VPackage.ActivityIntentInfo info, int match, int userId) {
    final VPackage.ActivityComponent activity = info.activity;
    PackageSetting ps = (PackageSetting) activity.owner.mExtras;
    ActivityInfo ai = PackageParserEx.generateActivityInfo(activity, mFlags, ps.readUserState(userId), userId);
    if (ai == null) {
        return null;
    }
    final ResolveInfo res = new ResolveInfo();
    res.activityInfo = ai;
    if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
        res.filter = info.filter;
    }
    res.priority = info.filter.getPriority();
    res.preferredOrder = activity.owner.mPreferredOrder;
    res.match = match;
    res.isDefault = info.hasDefault;
    res.labelRes = info.labelRes;
    res.nonLocalizedLabel = info.nonLocalizedLabel;
    res.icon = info.icon;
    return res;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:23,代码来源:VPackageManagerService.java

示例7: queryIntentForPackage

import android.content.pm.ResolveInfo; //导入依赖的package包/类
public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType, int flags,
                                               ArrayList<VPackage.ProviderComponent> packageProviders, int userId) {
    if (packageProviders == null) {
        return null;
    }
    mFlags = flags;
    final boolean defaultOnly = (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0;
    final int N = packageProviders.size();
    ArrayList<VPackage.ProviderIntentInfo[]> listCut = new ArrayList<>(N);

    ArrayList<VPackage.ProviderIntentInfo> intentFilters;
    for (int i = 0; i < N; ++i) {
        intentFilters = packageProviders.get(i).intents;
        if (intentFilters != null && intentFilters.size() > 0) {
            VPackage.ProviderIntentInfo[] array = new VPackage.ProviderIntentInfo[intentFilters
                    .size()];
            intentFilters.toArray(array);
            listCut.add(array);
        }
    }
    return super.queryIntentFromList(intent, resolvedType, defaultOnly, listCut, userId);
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:23,代码来源:ProviderIntentResolver.java

示例8: getCurLauncher

import android.content.pm.ResolveInfo; //导入依赖的package包/类
public static String getCurLauncher(Context context) {
    if (context == null) {
        return null;
    }

    try {
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_HOME);
        ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(mainIntent, 0);
        if (resolveInfo != null) {
            return resolveInfo.activityInfo.packageName;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}
 
开发者ID:by-syk,项目名称:NanoIconPack,代码行数:19,代码来源:PkgUtil.java

示例9: queryIntentServices

import android.content.pm.ResolveInfo; //导入依赖的package包/类
@Override
public List<ResolveInfo> queryIntentServices(Intent intent, String resolvedType, int flags) throws RemoteException {
    waitForReadyInner();
    try {
        enforcePluginFileExists();
        if (shouldNotBlockOtherInfo()) {
            return IntentMatcher.resolveServiceIntent(mContext, mPluginCache, intent, resolvedType, flags);
        } else {
            List<String> pkgs = mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
            List<ResolveInfo> infos = new ArrayList<ResolveInfo>();
            for (String pkg : pkgs) {
                intent.setPackage(pkg);
                List<ResolveInfo> list = IntentMatcher.resolveServiceIntent(mContext, mPluginCache, intent, resolvedType, flags);
                infos.addAll(list);
            }
            if (infos != null && infos.size() > 0) {
                return infos;
            }
        }
    } catch (Exception e) {
        handleException(e);
    }
    return null;
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:25,代码来源:IPluginManagerImpl.java

示例10: isGsaAvailable

import android.content.pm.ResolveInfo; //导入依赖的package包/类
/**
 * This is used to check whether GSA package is available to handle search requests and if
 * the Chrome experiment to do so is enabled.
 * @return Whether the search intent this class creates will resolve to an activity.
 */
public boolean isGsaAvailable() {
    if (mGsaAvailable != null) return mGsaAvailable;
    mGsaAvailable = false;
    PackageManager pm = mContext.getPackageManager();
    Intent searchIntent = new Intent(SEARCH_INTENT_ACTION);
    searchIntent.setPackage(GSAState.SEARCH_INTENT_PACKAGE);
    List<ResolveInfo> resolveInfo = pm.queryIntentActivities(searchIntent, 0);
    if (resolveInfo.size() == 0) {
        mGsaAvailable = false;
    } else if (!isPackageAboveVersion(SEARCH_INTENT_PACKAGE, GSA_VERSION_FOR_DOCUMENT)
            || !isPackageAboveVersion(GMS_CORE_PACKAGE, GMS_CORE_VERSION)) {
        mGsaAvailable = false;
    } else {
        mGsaAvailable = true;
    }
    return mGsaAvailable;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:GSAState.java

示例11: findSystemApk

import android.content.pm.ResolveInfo; //导入依赖的package包/类
static Pair<String, Resources> findSystemApk(String action, PackageManager pm) {
    final Intent intent = new Intent(action);
    for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) {
        if (info.activityInfo != null &&
                (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
            final String packageName = info.activityInfo.packageName;
            try {
                final Resources res = pm.getResourcesForApplication(packageName);
                return Pair.create(packageName, res);
            } catch (NameNotFoundException e) {
                Log.w(TAG, "Failed to find resources for " + packageName);
            }
        }
    }
    return null;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:17,代码来源:Utilities.java

示例12: testQueryActionViewIntentActivities

import android.content.pm.ResolveInfo; //导入依赖的package包/类
@Test
public void testQueryActionViewIntentActivities() throws Exception {
    File txt = new File("/test.txt");
    Uri uri = Uri.fromFile(txt);
    // 获取扩展名
    String extension = MimeTypeMap.getFileExtensionFromUrl(uri.toString());
    // 获取MimeType
    String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
    // 创建隐式Intent
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(uri, mimeType);

    Context context = InstrumentationRegistry.getContext();
    PackageManager packageManager = context.getPackageManager();
    // 根据Intent查询匹配的Activity列表
    List<ResolveInfo> resolvers =
            packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

    for (ResolveInfo resolver : resolvers) {
        Log.d(TAG, resolver.activityInfo.packageName + "\n" + resolver.activityInfo.name);
    }
}
 
开发者ID:JulianAndroid,项目名称:AppChooser,代码行数:23,代码来源:ResolversRepositoryTest.java

示例13: dispatchCaptureIntent

import android.content.pm.ResolveInfo; //导入依赖的package包/类
public void dispatchCaptureIntent(Context context, int requestCode) {
    Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (captureIntent.resolveActivity(context.getPackageManager()) != null) {
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (photoFile != null) {
            mCurrentPhotoPath = photoFile.getAbsolutePath();
            mCurrentPhotoUri = FileProvider.getUriForFile(mContext.get(),
                    mCaptureStrategy.authority, photoFile);
            captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentPhotoUri);
            captureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                List<ResolveInfo> resInfoList = context.getPackageManager()
                        .queryIntentActivities(captureIntent, PackageManager.MATCH_DEFAULT_ONLY);
                for (ResolveInfo resolveInfo : resInfoList) {
                    String packageName = resolveInfo.activityInfo.packageName;
                    context.grantUriPermission(packageName, mCurrentPhotoUri,
                            Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
                }
            }
            if (mFragment != null) {
                mFragment.get().startActivityForResult(captureIntent, requestCode);
            } else {
                mContext.get().startActivityForResult(captureIntent, requestCode);
            }
        }
    }
}
 
开发者ID:sathishmscict,项目名称:Matisse-Image-and-Video-Selector,代码行数:34,代码来源:MediaStoreCompat.java

示例14: validateAppSignatureForIntent

import android.content.pm.ResolveInfo; //导入依赖的package包/类
private boolean validateAppSignatureForIntent(Context context, Intent intent) {
    PackageManager pm = context.getPackageManager();
    ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
    if (resolveInfo == null) {
        return false;
    }
    try {
        for (Signature signature : pm.getPackageInfo(resolveInfo.activityInfo.packageName,
                64).signatures) {
            if (WEIBO_SIGNATURE.equals(signature.toCharsString())) {
                return true;
            }
        }
        return false;
    } catch (NameNotFoundException e) {
        return false;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:SinaSsoHandler.java

示例15: loadAsync

import android.content.pm.ResolveInfo; //导入依赖的package包/类
/**
 * Crappy async implementation
 *
 * @param info     the app to load the icon for
 * @param callback an interface to pass the adaptive icon to, or null if it cannot be obtained
 * @return the started thread
 */
public Thread loadAsync(final ResolveInfo info, final AsyncCallback callback) {
    Thread thread = new Thread() {
        @Override
        public void run() {
            final AdaptiveIcon icon = load(info);
            new Handler(Looper.getMainLooper()).post(new Runnable() {
                @Override
                public void run() {
                    callback.onResult(info, icon);
                }
            });
        }
    };
    thread.start();
    return thread;
}
 
开发者ID:TheAndroidMaster,项目名称:AdaptiveIconView,代码行数:24,代码来源:AdaptiveIcon.java


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