【发布时间】:2013-07-01 03:52:17
【问题描述】:
我有以下代码可以从我的 Android 应用中打开相机应用。它在三星 Galaxy Nexus 上运行良好,但在三星 Galaxy S3 上崩溃,不幸的是我没有后者的设备来调试问题,有什么建议吗?
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File dir = new File(Environment.getExternalStorageDirectory() + File.separator + this.getString(R.string.kda_images));
File file = new File(Environment.getExternalStorageDirectory() + File.separator + this.getString(R.string.kda_images) + File.separator + "Image-" + dir.listFiles().length + ".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));//The selected image is created in the specified location: file
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));//Refreshes the directory to show the new image
startActivityForResult(intent, CAPTURE_NEW_IMAGE);
【问题讨论】:
-
您是否尝试过从启动器启动相机应用程序?有时错误出在相机应用程序本身中,正如很多 S3 用户在这里所建议的那样 forums.androidcentral.com/t-galaxy-s-iii/…
-
相机工作正常
-
btw - 对于远程调试日志收集,我在商店中找到了一个名为 SendLog 的简单应用程序。也许它不是最好的,但它对我有用。否则一些在线崩溃收集服务,如 Crittercism。
标签: android android-camera android-camera-intent