Search code examples
javaandroidpermissionsappceleratortitanium-modules

Titanium module, android 6 permissions and overlay screen


I've a titanium module for android, but there are some doubts that I have, the module is to show a wrapped view with the back camera, that allows the user to take a picture or record a video but with the torch always on.

This is my java code: https://github.com/RicardoJCP/flashcam/blob/master/android/src/pt/flash/cam/android/ExampleProxy.java

I've all the methods working, but I had do add the permissions to work on android 6, but I don't know where to place it, since the module shows the surface view at the moment that it's created.

And I can't set the properties manually because the "Screen Overlay Detected".

It works fine in the previous versions of android, but the client has a Samsung Galaxy S7 and he can't use the app.

Any suggestion?


Solution

  • I think you should check if is Android 6 on the Titanium (js) app before initializing the module code. Something like this:

    if(Ti.Platform.Android.API_LEVEL >= 23)
    

    then, in the module, create a public method to check the camera permissions. I'm not using the newest Ti SDK, but for 5.1.2.GA I'm using this module: https://github.com/gimdongwoo/Ti-Android-RequestStoragePermission/tree/master/android for storage permissions, that actually makes use of the Camera permissions ;) Maybe you can use as a starting point or, make use of this module before yours.