Android Permissions

About Monkey 2 Forums Monkey 2 Programming Help Android Permissions

This topic contains 19 replies, has 6 voices, and was last updated by  PhatPeter 1 year, 6 months ago.

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #10998

    kheldar13
    Participant

    I am having trouble figuring out why the permissions for storage aren’t being set at install. When the app installs it says that there are no special permissions, and then I have to go into settings and manually set the storage permission. After that everything works fine. I have the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE set in the manifest, so I’m not sure why it isn’t being set at install. Any ideas?

    #11004

    Mark Sibly
    Keymaster

    Can you post/attach the manifest file here?

    #11024

    kheldar13
    Participant

    Here is the manifest.

    #11025

    kheldar13
    Participant

    <?xml version=”1.0″ encoding=”utf-8″?>

    <manifest
    xmlns:android=”http://schemas.android.com/apk/res/android”
    package=”com.sscalculator.bighatgames”>

    <uses-sdk android:minSdkVersion=”10″ android:targetSdkVersion=”23″ />

    <uses-feature android:glEsVersion=”0x00020000″ />

    <uses-permission android:name=”android.permission.INTERNET” />
    <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />
    <uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE” />
    <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />

    <application
    android:allowBackup=”true”
    android:icon=”@mipmap/ic_launcher”
    android:label=”@string/app_name”
    android:supportsRtl=”true”
    android:theme=”@style/AppTheme”>
    <activity
    android:name=”.SSCalculator”
    android:label=”SSCalculator”
    android:screenOrientation=”portrait”
    android:configChanges=”keyboardHidden|orientation|screenSize”
    android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”
    android:launchMode=”singleTop”>

    android:configChanges=”orientation”>

    <intent-filter>
    <action android:name=”android.intent.action.MAIN” />
    <category android:name=”android.intent.category.LAUNCHER” />
    </intent-filter>

    </activity>
    </application>

    </manifest>

    #11026

    CopperCircle
    Participant

    HI, if you are building for Android SDK 23+ you have to request permissions from the user not just in the manifest.

    This is the java module code I created for Monkey1 to deal with this:

    #11028

    Mark Sibly
    Keymaster

    Ok, just adding a permission module now.

    Thanks for the sample code coppercircle. Am I correct in thinking you also has to add the permissions callback to AppDelagate and main Actitiy class?

    #11033

    CopperCircle
    Participant

    Hi, yeah just a delagate and callback for the response

    #11035

    Mark Sibly
    Keymaster

    I actually meant the native target MonkeyActivity java class – my version doesn’t have the onPermissionsReply method.

    Ditto it’s not supported via the delegate mechanism. It’s easy enough to add, just wondering if I  missed a trick somewhere. I hate having to continually mung up the core Activity class each time we find something else that needs to be delegated out. It’s a pretty crappy design on the part of Android IMO.

    #11039

    CopperCircle
    Participant

    Yes unfortunately you have to add it to the target, I haven’t found anyway of of creating the delegate on the fly.

    #11073

    kheldar13
    Participant

    Thanks for the answers, guys. Greatly Appreciated.

    So how would I use this in Monkey2?

    #11075

    Mark Sibly
    Keymaster

    A version of this has been pushed to the develop branch of github. It will also be included in the v1.1.08 release due in a few days, so you can just wait for that if you want.

    Here it is in action, hopefully pretty straightforward:

    You might also want to read up on runtime permissions – was certainly news to me!

    https://developer.android.com/training/permissions/requesting.html

    You apparently only need to do this if targetSDK is >=23, which it is in the default manifest for monkey2 projects. So one way to avoid all this I guess is to just change targetSDK to 22!

    Thanks to CopperCircle for pointing me in the right direction.

    #11077

    kheldar13
    Participant

    Awesome!
    Thanks Mark.
    and Thanks CopperCircle

    #11079

    Mark Sibly
    Keymaster

    Also, can you let me know what you want to do with external storage?

    There are a lot of directories and APIS involved and I just wanna know what to concentrate on first.

    #11085

    kheldar13
    Participant

    Right now, I’m just using it to store user settings in a text file. Later, in a created directory, I may have some records(also in a text file) readable by other apps. So just text files at this point.

    #11087

    Diffrenzy
    Keymaster

    I would like to save some generated images and svg files to a user specified folder, maybe just “downloads” on Android. Not sure where to put them on iOS, but the new 11, might have some pointeres, because theres a file manager in that.

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic.