Guys,
Gideros comes with "Require" plugin for Android.
It looks like this is not exactly a plugin, but a way to add some permissions to the manifest.
My app needs to read files from the phone storage/SD card and process them.
I used the "Require" plugin to add "App needs to to write external storage" permission.
It adds it to the manifest (it only work for Android target 6.0 or lower by the way since what it adds is depreciated new newer versions of Android).
So when I set my target as Android 6 it adds "Storage" to app permissions.
The problem is that Android does not ask the user to Allow this permission.
It adds "Storage" to permissions, but the user has to go to App settings->Permissions and enable it manually. The "Allow" android dialog never comes.
The question is:
Do you know how to force this "Allow" dialog out of Gideros?
Thanks!
Comments
as you need
https://github.com/razorback456/gideros_tools/blob/master/require.gplugin
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Is there a way in Gideros to evoke ContextCompat.checkSelfPermission() and ActivityCompat.requestPermissions with specific permission, because having the permissions in the manifest does not help in some cases. The user has no way of turning them on inside the app (the popup does not appear).
I know that some of the plugins have code to check for specific permission (camera microphone), but the LFS plugin, for example, does not check for "Storage" permission (since it is low level and written in C I guess).
I see that there is some Example plugin that "Send a start event, wifi count and needed permissions. Can send a stop event."
Do you know if I can use this to ask for Storage permissions and if so how?
Thanks!
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
In android studio to request user permission through an app, you need to write some java code requesting those permissions. Now that google tells us to target android version 26 minimum I believe we need to implement this in all our apps.
I don't know gideros that much but one of my first test was to export a gideros sample to android studio. Then I had to update quite a few things like gradle and so.
Once all the updating was done in android studio I could write my java code and successfully run the demo on my android phone. You may try this way?
I wish gideros don't give up this option as it can be handy.
There is no way to do it with current Gideros APIs, I reckon the relevant Java code and lua bindings should be added to require plugin.
Likes: SinisterSoft, keszegh, pie
https://deluxepixel.com
Likes: MoKaLux
https://deluxepixel.com
I will probably try to add some java code to one of the existing plugins. I don't know exactly how to add new plugins in Android (only in iOS). Hope I don't have to change some C code, because I don't know how to compile it for Android.
By the way: Is there a tutorial of how to make plugin for Android - that has callbacks and stuff and how to compile it? I can try that...
Thanks
Likes: Apollo14
Likes: dreiko65, MoKaLux
Likes: dreiko65, MoKaLux, pie
https://deluxepixel.com
I have some java code for you.
1- export your gideros project to android studio
2- in the onCreate method:
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSION_WRITE_EXTERNAL_STORAGE:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
zprefsutil.myShowToast("SUPER.", 1);
} else {
zprefsutil.myShowToast(getApplicationContext().getString(R.string.nopermissionrw), 1);
}
break;
default:
break;
}
}
Hope that can help you.
nb1: i could not format the last piece of code because of special characters
nb2: you need to create the class with:
public class A01_MenuActivity extends Activity implements OnClickListener, OnRequestPermissionsResultCallback {
Likes: Apollo14, SinisterSoft
I added the code to my main activity class (instead of to some plugin java code).
(Needed to add:
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
and this do the build.gradle: implementation "com.android.support:support-v4:27.+"
and some static variable for PERMISSION_WRITE_EXTERNAL_STORAGE)
Now the "permission" dialog pops and asks for storage permission and when I "allow" - it sets the storage permissions in the app permission settings.
I do not have control in the lua (since it is not a plugin), but it sets the permission.
The problem is that the app has no access to the storage at all. Even though the permission is now set... I use LuaFileSystem calls and Gideros Texture.new to access the SD card content.
It works if the targetSdkVersion is 23.
Likes: MoKaLux
It is a feature I am planning to use later on and that doesn't work above sdk 23? Damn google! They really want us to use android studio!
Are you in a hurry?
Likes: Apollo14
Likes: Apollo14, MoKaLux, oleg
I have tested it on my Samsung J6 running android 9.
It saves your gfx to android pictures folder and the name of the file is: YYMMDD_HHMMSS_gideros.jpg
On windows 10, this will open the file explorer where you can change the file name.
Voilà.
Likes: oleg, Apollo14
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
This sample code is ready to use: copy/paste and voilà.
(you need to create a project of course!)
On windows that will open a save file dialog. On mac I don't know. On iPhone I don't know too.
Likes: Apollo14