0

I'm still having problems getting the Charm Down PicturesService to work. (I already posted a question regarding the issue).

Now I created a very simple test application and updated the build.gradle file with the latest library versions. However, the PicturesService is still working very unreliable. Selecting a picture sometimes works, sometimes it doesn't. Taking a picture seems to be working even more unreliable.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {   classpath 'org.javafxports:jfxmobile-plugin:1.3.5'}
}


apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.gluonapplication.GluonApplication'

dependencies {
    compile 'com.gluonhq:charm:4.3.4'
    compile 'org.javafxports:jfxdvk:8.60.9'
    compileNoRetrolambda 'com.airhacks:afterburner.mfx:1.6.2'
}

jfxmobile {
    downConfig {
        version = '3.3.0'
        plugins 'display', 'lifecycle', 'statusbar', 'storage', 'pictures'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
        compileSdkVersion = '23'

        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'license/LICENSE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'
        }
    }
}

The necessary permissions are added to the AndroidManifest:

<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

MobileApplication:

public class GluonApplication extends MobileApplication {

    @Override
    public void init() {

        addViewFactory(HOME_VIEW, () ->
            {

                PicturesService pictureService = Services.get(PicturesService.class)
                                                         .orElseThrow(() -> new IllegalStateException("Failed to get PictureService"));

                Button btnLoadImage = new Button("load image");
                btnLoadImage.setOnAction(e -> pictureService.loadImageFromGallery().ifPresent(i -> imv.setImage(i)));

                CheckBox chkSavePicture = new CheckBox("save picture");

                Button btnTakePhoto = new Button("take photo");
                btnTakePhoto.setOnAction(e -> pictureService.takePhoto(chkSavePicture.isSelected()).ifPresent(i -> imv.setImage(i)));

                ImageView imv= new ImageView();
                imv.setFitHeight(300);
                imv.setFitWidth(300);

                VBox content = new VBox(16, btnLoadImage, btnTakePhoto, chkSavePicture, imv);
                content.setAlignment(Pos.CENTER);

                return new View(content);
            });
    }
}

Tested on a Huawei P9 lite, Android 6.0

Logcat take photo succeeded:

05-13 16:08:49.200: V/FXActivity(18796): onActivityResult with requestCode 2 and resultCode = -1 and intent = null
05-13 16:08:50.180: V/FXActivity(18796): onRestart
05-13 16:08:50.187: V/FXActivity(18796): onStart
05-13 16:08:50.187: V/FXActivity(18796): onResume
05-13 16:08:50.196: V/FXEntity(18796): Surface created.
05-13 16:08:50.198: V/FXActivity native(18796): [JVDBG] SURFACE created native android window at 0xe7c9b208, surface = 0xffac4e60
05-13 16:08:50.202: D/mali_winsys(18796): new_window_surface returns 0x3000
05-13 16:08:50.202: I/GLASS(18796): Native code is notified that surface has changed (repaintall)!
05-13 16:08:50.203: V/FXEntity(18796): Called Surface changed [1080, 1740], format 4
05-13 16:08:50.203: V/FXActivity native(18796): [JVDBG] SURFACE created native android window at 0xe7c9b208, surface = 0xffac4e40
05-13 16:08:50.204: I/GLASS(18796): Native code is notified that surface has changed with size provided (repaintall)!
05-13 16:08:50.204: V/FXEntity(18796): Called Surface redraw needed
05-13 16:08:50.205: V/FXEntity(18796): Redraw...
05-13 16:08:50.205: I/GLASS(18796): Call surfaceRedrawNeeded
05-13 16:08:50.205: I/GLASS(18796): Native code is notified that surface needs to be redrawn (repaintall)!
05-13 16:08:50.205: V/FXEntity(18796): Wait a while before doing this again...
05-13 16:08:50.230: I/System.out(18796): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_20
05-13 16:08:50.310: I/System.out(18796): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_28
05-13 16:08:50.408: V/FXEntity(18796): Redraw again...
05-13 16:08:50.408: I/GLASS(18796): Call surfaceRedrawNeeded
05-13 16:08:50.408: I/GLASS(18796): Native code is notified that surface needs to be redrawn (repaintall)!
05-13 16:08:50.416: I/OpenGLRenderer(18796): Initialized EGL, version 1.4
05-13 16:08:50.419: D/mali_winsys(18796): new_window_surface returns 0x3000

Logcat take photo failed:

    05-13 22:18:38.264: I/art(9381): Late-enabling -Xcheck:jni
    05-13 22:18:38.299: D/ActivityThread(9381): ActivityThread,attachApplication
    05-13 16:07:13.229: D/HwCust(18033): Create obj success use class android.content.res.HwCustHwResourcesImpl
    05-13 16:07:13.393: I/MultiDex(18033): VM with version 2.1.0 has multidex support
    05-13 16:07:13.393: I/MultiDex(18033): install
    05-13 16:07:13.393: I/MultiDex(18033): VM has multidex support, MultiDex support library is disabled.
    05-13 16:07:13.429: V/FXActivity(18033): Initializing JavaFX Platform, using 8.60.9-SNAPSHOT
    05-13 16:07:13.438: V/FXActivity native(18033): Loading JavaFXDalvik library
    05-13 16:07:13.452: V/HwPolicyFactory(18033): : success to get AllImpl object and return....
    05-13 16:07:13.474: I/HwCust(18033): Constructor found for class android.app.HwCustHwWallpaperManagerImpl
    05-13 16:07:13.474: D/HwCust(18033): Create obj success use class android.app.HwCustHwWallpaperManagerImpl
    05-13 16:07:13.475: V/ActivityThread(18033): ActivityThread,callActivityOnCreate
    05-13 16:07:13.482: I/System.out(18033): usetextureview = false, useswipekeyboard = false
    05-13 16:07:13.484: I/HwSecImmHelper(18033): mSecurityInputMethodService is null
    05-13 16:07:13.485: V/FXActivity(18033): onCreate called, using 8.60.9-SNAPSHOT
    05-13 16:07:13.486: V/FXActivity native(18033): Notification queue instance created.
    05-13 16:07:13.486: V/FXActivity native(18033): Notification queue started
    05-13 16:07:13.498: V/HwWidgetFactory(18033): : successes to get AllImpl object and return....
    05-13 16:07:13.542: V/FXActivity native(18033): appDataDir: /data/user/0/com.gluonapplication
    05-13 16:07:13.543: V/FXActivity(18033): onStart
    05-13 16:07:13.544: D/ActivityThread(18033): add activity client record, r= ActivityRecord{a0b6377 token=android.os.BinderProxy@a432176 {com.gluonapplication/javafxports.android.FXActivity}} token= android.os.BinderProxy@a432176
    05-13 16:07:13.544: V/FXActivity(18033): onActivityResult with requestCode 2 and resultCode = -1 and intent = null
    05-13 16:07:13.544: V/FXActivity(18033): onResume
    05-13 16:07:13.566: D/OpenGLRenderer(18033): Use EGL_SWAP_BEHAVIOR_PRESERVED: false
    05-13 16:07:13.638: I/OpenGLRenderer(18033): Initialized EGL, version 1.4
    05-13 16:07:13.655: D/mali_winsys(18033): new_window_surface returns 0x3000
    05-13 16:07:13.665: V/FXEntity(18033): Surface created.
    05-13 16:07:13.666: V/FXActivity native(18033): [JVDBG] SURFACE created native android window at 0xe7c99d08, surface = 0xffac4f30
    05-13 16:07:13.816: I/System.out(18033): user.locale=de-DE
    05-13 16:07:13.816: I/System.out(18033): javax.xml.stream.XMLEventFactory=com.sun.xml.stream.events.ZephyrEvent...
    05-13 16:07:13.816: I/System.out(18033): prism.text=native
    05-13 16:07:13.816: I/System.out(18033): java.vendor.url=http://www.android.com/
    05-13 16:07:13.816: I/System.out(18033): java.ext.dirs=
    05-13 16:07:13.816: I/System.out(18033): line.separator=
    05-13 16:07:13.816: I/System.out(18033): file.encoding=UTF-8
    05-13 16:07:13.816: I/System.out(18033): java.runtime.version=0.9
    05-13 16:07:13.816: I/System.out(18033): prism.dirtyopts=true
    05-13 16:07:13.816: I/System.out(18033): user.name=root
    05-13 16:07:13.816: I/System.out(18033): java.compiler=
    05-13 16:07:13.816: I/System.out(18033): android.icu.unicode.version=7.0
    05-13 16:07:13.816: I/System.out(18033): javax.xml.stream.XMLOutputFactory=com.sun.xml.stream.ZephyrWriterFactory
    05-13 16:07:13.816: I/System.out(18033): prism.debugfonts=true
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.gestures.rotate=true
    05-13 16:07:13.816: I/System.out(18033): java.version=0
    05-13 16:07:13.816: I/System.out(18033): android.icu.library.version=55.1
    05-13 16:07:13.816: I/System.out(18033): use.egl=true
    05-13 16:07:13.816: I/System.out(18033): embedded=monocle
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.gestures.scroll=true
    05-13 16:07:13.816: I/System.out(18033): prism.lcdtext=false
    05-13 16:07:13.816: I/System.out(18033): os.arch=armv7l
    05-13 16:07:13.816: I/System.out(18033): java.io.tmpdir=/data/user/0/com.gluonapplication/cache
    05-13 16:07:13.816: I/System.out(18033): glass.platform=Monocle
    05-13 16:07:13.816: I/System.out(18033): android.zlib.version=1.2.8
    05-13 16:07:13.816: I/System.out(18033): user.language=de
    05-13 16:07:13.816: I/System.out(18033): java.vm.version=2.1.0
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.isEmbedded=true
    05-13 16:07:13.816: I/System.out(18033): javax.xml.stream.XMLInputFactory=com.sun.xml.stream.ZephyrParserFactory
    05-13 16:07:13.816: I/System.out(18033): prism.glDepthSize=16
    05-13 16:07:13.816: I/System.out(18033): path.separator=:
    05-13 16:07:13.816: I/System.out(18033): java.runtime.name=Android Runtime
    05-13 16:07:13.816: I/System.out(18033): java.specification.version=0.9
    05-13 16:07:13.816: I/System.out(18033): user.dir=/
    05-13 16:07:13.816: I/System.out(18033): prism.maxTextureSize=2048
    05-13 16:07:13.816: I/System.out(18033): java.vm.specification.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): com.sun.javafx.gestures.zoom=true
    05-13 16:07:13.816: I/System.out(18033): java.vm.name=Dalvik
    05-13 16:07:13.816: I/System.out(18033): monocle.platform=Android
    05-13 16:07:13.816: I/System.out(18033): log.lens=FINEST
    05-13 16:07:13.816: I/System.out(18033): java.vm.specification.version=0.9
    05-13 16:07:13.816: I/System.out(18033): user.home=
    05-13 16:07:13.816: I/System.out(18033): java.specification.name=Dalvik Core Library
    05-13 16:07:13.816: I/System.out(18033): file.separator=/
    05-13 16:07:13.816: I/System.out(18033): java.library.path=/vendor/lib:/system/lib
    05-13 16:07:13.816: I/System.out(18033): user.variant=
    05-13 16:07:13.816: I/System.out(18033): os.version=3.10.90-g033208c
    05-13 16:07:13.816: I/System.out(18033): java.boot.class.path=/system/framework/core-libart.jar:/sy...
    05-13 16:07:13.816: I/System.out(18033): DALVIK.prism.verbose=true
    05-13 16:07:13.816: I/System.out(18033): java.vm.specification.name=Dalvik Virtual Machine Specification
    05-13 16:07:13.816: I/System.out(18033): javafx.platform=android
    05-13 16:07:13.816: I/System.out(18033): glass.lens=eglfb
    05-13 16:07:13.816: I/System.out(18033): os.name=Linux
    05-13 16:07:13.816: I/System.out(18033): user.region=DE
    05-13 16:07:13.816: I/System.out(18033): java.class.path=.
    05-13 16:07:13.816: I/System.out(18033): android.icu.impl.ICUBinary.dataPath=/data/misc/zoneinfo/current/icu:/syst...
    05-13 16:07:13.816: I/System.out(18033): prism.verbose=true
    05-13 16:07:13.816: I/System.out(18033): prism.vsync=false
    05-13 16:07:13.816: I/System.out(18033): java.specification.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): java.vm.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): prism.allowhidpi=true
    05-13 16:07:13.816: I/System.out(18033): java.vendor=The Android Project
    05-13 16:07:13.816: I/System.out(18033): http.agent=Dalvik/2.1.0 (Linux; U; Android 6.0; ...
    05-13 16:07:13.816: I/System.out(18033): android.icu.cldr.version=27.0.1
    05-13 16:07:13.816: I/System.out(18033): android.openssl.version=BoringSSL
    05-13 16:07:13.817: I/System.out(18033): java.home=/system
    05-13 16:07:13.817: I/System.out(18033): java.vm.vendor.url=http://www.android.com/
    05-13 16:07:13.817: I/System.out(18033): java.class.version=50.0
    05-13 16:07:13.817: V/DalvikLauncher(18033): Launch JavaFX application on DALVIK vm.
    05-13 16:07:13.848: V/DalvikLauncher(18033): We have JavaFX on our current (base) classpath, registered exit listener
    05-13 16:07:13.854: V/DalvikLauncher(18033): application class: [class com.gluonapplication.GluonApplication]
    05-13 16:07:13.854: V/DalvikLauncher(18033): preloader class: [null]
    05-13 16:07:13.854: V/DalvikLauncher(18033): javafx application class: [class javafx.application.Application]
    05-13 16:07:13.854: V/DalvikLauncher(18033): javafx launcher class: [class com.sun.javafx.application.LauncherImpl]
    05-13 16:07:13.854: V/DalvikLauncher(18033): launch application method: [public static void com.sun.javafx.application.LauncherImpl.launchApplication(java.lang.Class,java.lang.Class,java.lang.String[])]
    05-13 16:07:13.871: V/FXEntity(18033): Called Surface changed [1080, 1740], format 4
    05-13 16:07:13.871: V/FXActivity native(18033): [JVDBG] SURFACE created native android window at 0xe7c99d08, surface = 0xffac4f10
    05-13 16:07:13.871: V/FXEntity(18033): Called Surface redraw needed
    05-13 16:07:13.878: V/FXEntity(18033): Called Surface redraw needed
    05-13 16:07:13.993: I/System.out(18033): Prism pipeline init order: es2 
    05-13 16:07:13.993: I/System.out(18033): Using native-based Pisces rasterizer
    05-13 16:07:13.993: I/System.out(18033): Using dirty region optimizations
    05-13 16:07:13.993: I/System.out(18033): Using system sized mask for primitives
    05-13 16:07:13.993: I/System.out(18033): Not forcing power of 2 sizes for textures
    05-13 16:07:13.993: I/System.out(18033): Using hardware CLAMP_TO_ZERO mode
    05-13 16:07:13.993: I/System.out(18033): Opting in for HiDPI pixel scaling
    05-13 16:07:14.000: I/System.out(18033): Prism pipeline name = com.sun.prism.es2.ES2Pipeline
    05-13 16:07:14.010: I/System.out(18033): Loading ES2 native library ... prism_es2_monocle
    05-13 16:07:14.023: I/System.out(18033):    succeeded.
    05-13 16:07:14.023: I/System.out(18033): GLFactory using com.sun.prism.es2.MonocleGLFactory
    05-13 16:07:14.054: I/GLASS(18033): I have to Call dlopen libGLESv2.so
    05-13 16:07:14.055: I/GLASS(18033): handle = 0xf76fcd04
    05-13 16:07:14.055: I/GLASS(18033): I have to Call dlopen libEGL.so
    05-13 16:07:14.056: I/GLASS(18033): handle = 0xf76fc9c4
    05-13 16:07:14.057: I/GLASS(18033): Binding to libactivity.so
    05-13 16:07:14.058: I/GLASS(18033): GetNativeWindow = 0xf3762da1, getDensitiy = 0xf3762dad
    05-13 16:07:14.058: V/FXEntity(18033): notify_glassHasStarted called in FXActivity. register device now.
    05-13 16:07:14.079: D/mali_winsys(18033): new_window_surface returns 0x3000
    05-13 16:07:14.089: I/System.out(18033): (X) Got class = class com.sun.prism.es2.ES2Pipeline
    05-13 16:07:14.104: I/System.out(18033): Initialized prism pipeline: com.sun.prism.es2.ES2Pipeline
    05-13 16:07:14.127: I/DENSITY(18033): GETDENSITY, answer = 3.000000
    05-13 16:07:14.185: I/System.out(18033): Maximum supported texture size: 8192
    05-13 16:07:14.186: I/System.out(18033): Maximum texture size clamped to 2048
    05-13 16:07:14.186: I/System.out(18033): Non power of two texture support = true
    05-13 16:07:14.186: I/System.out(18033): Maximum number of vertex attributes = 16
    05-13 16:07:14.186: I/System.out(18033): Maximum number of uniform vertex components = 4096
    05-13 16:07:14.186: I/System.out(18033): Maximum number of uniform fragment components = 4096
    05-13 16:07:14.186: I/System.out(18033): Maximum number of varying components = 60
    05-13 16:07:14.186: I/System.out(18033): Maximum number of texture units usable in a vertex shader = 16
    05-13 16:07:14.186: I/System.out(18033): Maximum number of texture units usable in a fragment shader = 16
    05-13 16:07:14.190: I/System.out(18033): Graphics Vendor: ARM
    05-13 16:07:14.191: I/System.out(18033):        Renderer: Mali-T830
    05-13 16:07:14.192: I/System.out(18033):         Version: OpenGL ES 3.1 v1.r8p0-01dev0.bbfc5a14ef62ccdf784a9fff6af72acd
    05-13 16:07:14.216: I/System.out(18033): register device done
    05-13 16:07:14.227: W/System.err(18033):  vsync: false vpipe: true
    05-13 16:07:14.227: I/System.out(18033): [MON] Create device
    05-13 16:07:14.230: I/System.out(18033): [MON] Create device done, add done
    05-13 16:07:14.414: W/System.err(18033): Loading FontFactory com.sun.javafx.font.freetype.FTFactory
    05-13 16:07:14.414: W/System.err(18033): Subpixel: enabled
    05-13 16:07:14.434: W/System.err(18033): Freetype2 Loaded (version 2.5.0)
    05-13 16:07:14.434: W/System.err(18033): LCD support Enabled
    05-13 16:07:14.444: W/art(18033): Before Android 4.1, method void com.sun.javafx.scene.transform.TransformUtils$ImmutableTransform.ensureCanTransform2DPoint() would have incorrectly overridden the package-private method in javafx.scene.transform.Transform
    05-13 16:07:14.630: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF415078203.tmp
    05-13 16:07:14.643: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF1552782793.tmp
    05-13 16:07:14.650: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF-728135178.tmp
    05-13 16:07:14.657: W/System.err(18033): Temp file created: /data/user/0/com.gluonapplication/cache/+JXF-646868817.tmp
    05-13 16:07:14.828: W/art(18033): Before Android 4.1, method double javafx.scene.text.TextFlow.computeChildPrefAreaHeight(javafx.scene.Node, javafx.geometry.Insets) would have incorrectly overridden the package-private method in javafx.scene.layout.Region
    05-13 16:07:14.828: W/art(18033): Before Android 4.1, method double javafx.scene.text.TextFlow.computeChildPrefAreaWidth(javafx.scene.Node, javafx.geometry.Insets) would have incorrectly overridden the package-private method in javafx.scene.layout.Region
    05-13 16:07:15.067: I/System.out(18033): max rectangle texture cell size = 62
    05-13 16:07:15.084: I/System.out(18033): wrap rectangle texture = 2 x 2
    05-13 16:07:15.087: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: AlphaTexture_Color.frag
    05-13 16:07:15.106: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: Texture_Color.frag
    05-13 16:07:15.122: I/System.out(18033): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_20
    05-13 16:07:15.133: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: Solid_TextureRGB.frag
    05-13 16:07:15.150: I/System.out(18033): ES2ResourceFactory: Prism - createStockShader: FillRoundRect_Color.frag
    05-13 16:07:15.154: I/System.out(18033): Loading Prism common native library ...
    05-13 16:07:15.163: I/System.out(18033):    succeeded.
    05-13 16:07:15.177: I/System.out(18033): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_28
Community
  • 1
  • 1
jns
  • 6,017
  • 2
  • 23
  • 28
  • The second logcat seems to show the messages of a new app being launched after the action fails? Can you describe what "fails" means? I.e., the camera is not even launched; the camera is launched and after taking the picture, the app stays black and fails to load it and then restarts again... – José Pereda May 13 '17 at 19:35
  • If you could clone the `PictureService` from [here](https://bitbucket.org/gluon-oss/charm-down/src/dd598e67be7827ab3861d9f0831d4e5d6da47f3f/plugins/plugin-pictures/?at=default), rename to `MyPictureService` and include it in your project (`AndroidMyPictureService`), and add some System.out messages to track the different steps when the service works and fails, that could help. – José Pereda May 13 '17 at 19:39
  • "Fails" means the camera / gallery is launched, photo is taken / selected, everything works fine, but the app gets restarted, instead of being resumed. – jns May 13 '17 at 19:59
  • Though there's a result (logmessage: `onActivityResult with requestCode 2 and resultCode = -1 and intent = null`), it seems like the `activityResultHandler` is not entered. But at that the point, the app is already startet again -> `onStart, activityResult, onResume` instead of `activityResult, onRestart, onStart, onResume`, (The first two lines of the logcat were missing, I've added them to the question) – jns May 13 '17 at 20:38
  • You get the right flags for requestCode and resultCode. But it could be a silent exception after this [line](https://bitbucket.org/gluon-oss/charm-down/src/dd598e67be7827ab3861d9f0831d4e5d6da47f3f/plugins/plugin-pictures/android/src/main/java/com/gluonhq/charm/down/plugins/android/AndroidPicturesService.java?at=default&fileviewer=file-view-default#AndroidPicturesService.java-97), that causes the app to crash and restart. Can you check if this is the case adding some try-catch to that block? – José Pereda May 13 '17 at 21:36
  • Like before, no exception, nothing, just a restart – jns May 13 '17 at 21:50
  • Are you checking that the different steps succeed? i.e. print out `selectedImagePath`, `converted`, ... or even comment out the scanFile. – José Pereda May 13 '17 at 22:53
  • Yes I've already tried that, and I added a log message as first line (after the try) in the activityResultHandler as well, to see if the resultHandler is called, which is not the case when the app is restarted. When there is a proper resume, all the log messages are there – jns May 13 '17 at 23:18
  • You are getting a null intent. See [here](https://bitbucket.org/javafxports/8u-dev-rt/src/46e9c63f0d388f9dbc3302cf081e640328ac0951/modules/graphics/src/dalvik/java/javafxports/android/FXActivity.java?at=default&fileviewer=file-view-default#FXActivity.java-165): it won't process the intentHandler. When I run it I get `onActivityResult with requestCode 2 and resultCode = -1 and intent = Intent { }`. See this [question](http://stackoverflow.com/questions/12564112/android-camera-onactivityresult-intent-is-null-if-it-had-extras). Can you comment out `intent.putExtra()` and check again? – José Pereda May 13 '17 at 23:51
  • That seems to work a lot better. I was able to take 5 - 8 pictures before there was a restart. But how do I access the picture? – jns May 14 '17 at 00:08
  • Can you try `Uri selectedImage = data.getData()`? – José Pereda May 14 '17 at 00:58
  • data.getData() == null – jns May 14 '17 at 01:06
  • Can you go back again, and use `putExtra`, but replace the `photoUri` with this: `Uri photoUri = ACTIVITY.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues()); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);`, and try again? That gives me a picture at file:///storage/emulated/0/Pictures/1494754359025.jpg, i.e. /sdcard/Pictures/1494754359025.jpg. – José Pereda May 14 '17 at 09:39
  • The picture is there, but intent == null again – jns May 14 '17 at 13:06
  • @José I've replaced `photoUri`again with: ` Uri photoUri = FileProvider.getUriForFile(ACTIVITY, "package.fileprovider", targetFile)` which seems to be working better, though still not reliable. `intent`is still null. – jns May 21 '17 at 00:55
  • @JoséPereda works perfectly on Android 7.0 (Huawei EMUI 5.0) – jns Jun 13 '17 at 16:43
  • So it's a matter of devices? Are those you have tested so different? In terms of Android OS I mean. – José Pereda Jun 13 '17 at 16:47
  • It's the same device, huawei p9 lite, but I updated to Android 7.0. Unfortunately there is a new error I described [here](https://stackoverflow.com/questions/44528029/gluon-view-layout-displaced-after-taking-a-picture) – jns Jun 13 '17 at 17:34

0 Answers0