小智 10
你试过这个吗?
PackageManager packman = getPackageManager();
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
String pack = intent.resolveActivity(packman).getPackageName();
Run Code Online (Sandbox Code Playgroud)
我不确定,但我认为您可以使用指定的意图获取应用程序的包名称.
查看此代码以获取处理特定意图的可用应用程序信息,
/**
* Indicates whether the specified action can be used as an intent. This
* method queries the package manager for installed packages that can
* respond to an intent with the specified action. If no suitable package is
* found, this method returns false.
*
* @param context The application's environment.
* @param action The Intent action to check for availability.
*
* @return True if an Intent with the specified action can be sent and
* responded to, false otherwise.
*/
public static boolean isIntentAvailable(Context context, String action) {
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
List list =
packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
Run Code Online (Sandbox Code Playgroud)
现在使用Camera intent,您可以获取处理IMAGE_CAPTURE意图的应用程序信息,并使用该信息轻松获取包名称.
更新:
在您的情况下,具体意图是
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Run Code Online (Sandbox Code Playgroud)
编辑:
List<ResolveInfo> listCam = packageManager.queryIntentActivities(intent, 0);
for (ResolveInfo res : listCam) {
Log.e("Camera Application Package Name and Activity Name",res.activityInfo.packageName + " " + res.activityInfo.name));
}
Run Code Online (Sandbox Code Playgroud)
试试这个让我知道发生了什么......
| 归档时间: |
|
| 查看次数: |
8137 次 |
| 最近记录: |