我只想打电话给系统相机拍照不是来自第三方。我无法从第三方获得结果,也无法从第三方获得结果。
以下是我的代码;
Intent intent2 = new Intent();
Intent intent_camera = getPackageManager().getLaunchIntentForPackage("com.android.camera");
if (intent_camera != null) {
intent2.setPackage("com.android.camera");
}
intent2.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
答案 0 :(得分:0)
你必须做这样的事情。实施onActivityResult
以捕获结果
String name = dateToString(new Date(), "yyyy-MM-dd-hh-mm-ss");
destination = new File(Environment
.getExternalStorageDirectory(), Filename + ".jpg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(destination));
startActivityForResult(intent, PICK_Camera_IMAGE);
答案 1 :(得分:0)
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo: list) {
if (resolveInfo.activityInfo.applicationInfo.
// update to account for unlikely camera app update:
flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP))
// worse approach:
// sourceDir.startsWith("/system/app")) {
intent.setClassName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name);
break;
}
}
startActivityForResult(intent, actionCode);