Recent

Author Topic: LAMW how to request special overlay permission [SOLVED]  (Read 2116 times)

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
LAMW how to request special overlay permission [SOLVED]
« on: August 17, 2020, 11:05:55 pm »
Hi people, i try the AppWindowManagerDemo1 before and work fine but with my new phono and android 10 no work fine, a make some search and this required an overlay permission but i change it on the manifest adding this:
Code: Pascal  [Select][+][-]
  1. <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
and in the source code:
Code: Pascal  [Select][+][-]
  1. if IsRuntimePermissionsNeed() then
  2. begin
  3.   SetLength(manifestpermissions,1);
  4.   manifestPermission:='android.permission.SYSTEM_ALERT_WINDOW';
  5.   self.RequestRuntimePermission(manifestPermissions, 2001);
  6.   SetLength(manifestpermissions,0);
  7. end;
  8.  
  9.  
not permission is requested and if i add the permission manually and try to do:
Code: Pascal  [Select][+][-]
  1. jwindowManager1.addview(jpanel1.view);
  2. jwindowmanager1.SetViewRoudCorner();
  3. self.minimize();
the app crach
« Last Edit: August 21, 2020, 06:24:33 pm by Segator »
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
Re: LAMW how to request special overlay permission
« Reply #1 on: August 18, 2020, 07:32:09 pm »
I fix the manifest xml file, now the project work in Andorid 7.0 (emultator) but still having 2 problems:

1: AppWindowManagerDemo1 not run in Android 10 (Samsung A10s)
2: I have to set the overlay permision manually.
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: LAMW how to request special overlay permission
« Reply #2 on: August 18, 2020, 07:38:56 pm »
Quote
I have to set the overlay permision manually.

How?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
Re: LAMW how to request special overlay permission
« Reply #3 on: August 18, 2020, 07:43:06 pm »
Quote
I have to set the overlay permision manually.

How?
in the phone general settings permision, because this
Code: Pascal  [Select][+][-]
  1. if IsRuntimePermissionsNeed() then
  2. begin
  3.   SetLength(manifestpermissions,1);
  4.   manifestPermission:='android.permission.SYSTEM_ALERT_WINDOW';
  5.   self.RequestRuntimePermission(manifestPermissions, 2001);
  6.   SetLength(manifestpermissions,0);
  7. end;
not work for me

and even with the manualy permission granted work only in Android 7, crach in Android 10.
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
Re: LAMW how to request special overlay permission
« Reply #4 on: August 18, 2020, 07:54:08 pm »
I found this
Code: Pascal  [Select][+][-]
  1. @RequiresApi(api = Build.VERSION_CODES.M)
  2.   public void checkDrawOverlayPermission() {
  3.    Log.v("App", "Package Name: " + getApplicationContext().getPackageName());
  4.  
  5.    // check if we already  have permission to draw over other apps
  6.    if (!Settings.canDrawOverlays(context)) {
  7.     Log.v("App", "Requesting Permission" + Settings.canDrawOverlays(context));
  8.     // if not construct intent to request permission
  9.     Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
  10.      Uri.parse("package:" + getApplicationContext().getPackageName()));
  11.     / request permission via start activity for result
  12.     startActivityForResult(intent, REQUEST_CODE);
  13.    } else {
  14.     Log.v("App", "We already have permission for it.");
  15.     disablePullNotificationTouch();
  16.    }
  17.   }
and i try to do this:
Code: Pascal  [Select][+][-]
  1.     jIntentManager1.SetAction('Settings.ACTION_MANAGE_OVERLAY_PERMISSION');
  2.     jIntentManager1.SetDataUriAsString('package: '+gapp.PackageName);
  3.     jIntentManager1.StartActivityForResult(1001);
but nothing is happend.
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
Re: LAMW how to request special overlay permission
« Reply #5 on: August 19, 2020, 04:09:59 pm »
I note other problem running the demo for jWindowManager componet, when htey show like a floating window never lost the focus and the back button not work in other apps then.
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
Re: LAMW how to request special overlay permission
« Reply #6 on: August 19, 2020, 06:32:04 pm »
i found this https://blog.floatingapps.net/2019/11/cant-grant-permissions-to-fa-because-of-draw-over-other-apps/ basically in android 10 you can't request other permission after the overlay permission grant, you must request this permission before others, about the always focused window i try to make a wrapper to the SetViewFocusable procedure in jWindowManager.java and if a call this the application crach
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
Re: LAMW how to request special overlay permission
« Reply #7 on: August 21, 2020, 06:24:15 pm »
Finally i solved this particular request permission, i send a pull request to github, when this change you can do something like this:

Code: Pascal  [Select][+][-]
  1. jIntentManager1.SetAction(iaManageOverlayPermission);
  2. jIntentManager1.SetDataUriAsString('package:'+gapp.PackageName);
  3. jIntentManager1.StartActivityForResult(1006);
  4.  

but for now i can't know if the permission is granted or not.
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: LAMW how to request special overlay permission [SOLVED]
« Reply #8 on: August 21, 2020, 07:47:32 pm »

You can try handle event  the "OnActivityResult"   from jForm...
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Segator

  • Full Member
  • ***
  • Posts: 168
    • https://github.com/Nenirey
Re: LAMW how to request special overlay permission [SOLVED]
« Reply #9 on: August 21, 2020, 08:20:45 pm »
i try it but the variable resultCode only manage RESULT_CANCELED and RESULT_OK with no change effect in action manage overlay permission window, even with the overlay button active is not a result_ok.

edited:
this not work:
Code: Pascal  [Select][+][-]
  1. if resultCode = RESULT_OK then
  2. ShowMessage('done');
the toast never prompt
« Last Edit: August 21, 2020, 08:26:25 pm by Segator »
i am Reinier, Nenirey and Segator :) https://github.com/Nenirey

 

TinyPortal © 2005-2018