Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Request permissions #524

Open
nomeata opened this issue Sep 7, 2019 · 7 comments
Open

Android: Request permissions #524

nomeata opened this issue Sep 7, 2019 · 7 comments

Comments

@nomeata
Copy link
Contributor

nomeata commented Sep 7, 2019

My Android app should write some files to /sdcard. It seems that if I add

    permissions = ''
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    '';

to the call to buildApp and then manually in the App’s settings enable these permissions, I can access the /sdcard. So that’s a start.

But clearly, the proper way is to ask the system at runtime to give the app these permissions.

Is that supported from Haskell (somehow)?

nomeata added a commit to nomeata/kaleidogen that referenced this issue Sep 7, 2019
more progress needs some way to request for permissions at runtime
see reflex-frp/reflex-platform#524
@ali-abrar
Copy link
Member

The behavior used to be that when you tried to use a permission that had not been granted, the authorization modal would appear. Somewhere along the way that must have stopped working, probably due to changes in how the android sdk.

Relevant documentation

Relevant code in android-activity

I'll look into this. Is the app you're building open source? Perhaps I can use that as a test.

@ali-abrar
Copy link
Member

Oh, I see. kaleidogen.

Is there a particular branch I should build?

@nomeata
Copy link
Contributor Author

nomeata commented Sep 8, 2019

This was just an experiment so far, but yeah, check branch android-writing-files.

You should be able to build the app using nix-build -A android. After changing the path from /home/jojo/build/haskell/reflex/reflex-platform in default.nix to something else…

@nomeata
Copy link
Contributor Author

nomeata commented Sep 8, 2019

Maybe I shouldn’t worry about writing to storage, and instead write to the app-internal storage and then use the “send intent” to share the file. But I fear that accessing the API to invoke intents from Haskell is no easier than asking for extra permissions (and I guess in general using any feature of the Android API from Haskell, without writing Java and JNI stuff, is going to be too tricky).

@nomeata
Copy link
Contributor Author

nomeata commented Sep 8, 2019

I wonder if http://hackage.haskell.org/package/jvm would work on Android…

@nomeata
Copy link
Contributor Author

nomeata commented Sep 8, 2019

Doesn’t look like it (yet): tweag/inline-java#92

@nomeata
Copy link
Contributor Author

nomeata commented Aug 30, 2020

Coming back to this (every few months I am trying to make small improvements). Did your investigation lead to anything? Do you have any apps that save files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants