【问题标题】:Code for open camera on Android does not work in Samsung S3Android 上打开相机的代码在三星 S3 中不起作用
【发布时间】: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


【解决方案1】:

请尝试使用下面的代码,因为我的结果是它在 Galaxy s3 设备中正常工作。

意图动作 = new Intent("android.media.action.IMAGE_CAPTURE") action.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString()); startActivityForResult(action,TAKE_PICTURE_FROM_CAMERA);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    相关资源
    最近更新 更多