Android: App crashes on onActivityResult while using Camera Intent

后端 未结 8 1588
一整个雨季
一整个雨季 2020-12-11 14:40

I am using camera intent to capture images in my App. The problem my app crashes on Android 5.0.2 while using camera. I am using intent from fragment. Below is

8条回答
  •  旧巷少年郎
    2020-12-11 15:36

    As per the logs

    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.getScheme()' on a null object reference
    

    It clearly states that you are calling getScheme() on a null object. So before processing, you need to check for null intent data.

    Also, beginning with Android M, you need to ask user for Camera permission. In lack of camera permission, app will crash.

    To know how to work with new permission architecture, look over it: http://developer.android.com/training/permissions/index.html

提交回复
热议问题