whd6107
whd6107
采纳率0%
2017-05-09 17:20 阅读 7.3k

MediaStore.ACTION_IMAGE_CAPTURE无法调起相机应用

点击按钮后,无法调起相机,直接退出对应Activity,请教原因!!!
代码:
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent capIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(capIntent,100);
}
});

AndroidManifest.xml:
    <uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-feature android:name="android.hardware.camera2"></uses-feature>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • whd6107 whd6107 2017-05-09 17:20

    补充执行日志:
    05-10 01:19:03.235 27684-27710/com.example.administrator.androidtuborial E/OpenGLRenderer: allen debug liyu Key: 5242948
    05-10 01:19:03.295 27684-27684/com.example.administrator.androidtuborial D/AndroidRuntime: Shutting down VM
    05-10 01:19:03.296 27684-27684/com.example.administrator.androidtuborial E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.administrator.androidtuborial, PID: 27684
    java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE cmp=com.huawei.camera/.ThirdCamera } from ProcessRecord{d26d862 27684:com.example.administrator.androidtuborial/u0a142} (pid=27684, uid=10142) with revoked permission android.permission.CAMERA
    at android.os.Parcel.readException(Parcel.java:1665)
    at android.os.Parcel.readException(Parcel.java:1618)
    at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3097)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1539)
    at android.app.Activity.startActivityForResult(Activity.java:4391)
    at android.app.Activity.startActivityForResult(Activity.java:4335)
    at com.example.administrator.androidtuborial.CaptureActivity$1.onClick(CaptureActivity.java:30)
    at android.view.View.performClick(View.java:5647)
    at android.view.View$PerformClick.run(View.java:22465)
    at android.os.Handler.handleCallback(Handler.java:761)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:199)
    at android.app.ActivityThread.main(ActivityThread.java:6585)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
    05-10 01:19:03.312 27684-27684/com.example.administrator.androidtuborial I/Process: Sending signal. PID: 27684 SIG: 9

    点赞 评论 复制链接分享
  • MacaoPark Xia_燚 2017-05-10 02:04
    点赞 评论 复制链接分享
  • MacaoPark Xia_燚 2017-05-11 03:22

    图片说明

    点赞 评论 复制链接分享
  • GracefulGuigui 绿叶青年 2020-02-14 18:36

    添加这个权限试试

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    
    点赞 评论 复制链接分享

相关推荐