android - Windowmanager addView permisssion inside the Broadcastreceiver for marshmallow and above -


i have windowmanager pop when there event match mentioned in broadcastreceiver. working fine before marshmallow , marshmallow requires overlay permission provided per below in activity.

 public boolean checkdrawoverlaypermission() {     if (build.version.sdk_int < build.version_codes.m) {         return true;     }     if (!settings.candrawoverlays(this)) {         intent intent = new intent(settings.action_manage_overlay_permission,                 uri.parse("package:" + getpackagename()));         startactivityforresult(intent, request_code);         return false;     } else {         return true;     } } 

also provided following in android manifest.

<uses-permission android:name="android.permission.system_alert_window" /> 

and broadcast receiver looks below.

public class bcast extends broadcastreceiver {      @override     public void onreceive(context context, intent intent) {         if (intent.getaction().equals(sms_received))         {          final windowmanager windowmanager = (windowmanager) otpreader.this.getsystemservice(window_service);         layoutinflater inflater = (layoutinflater) otpreader.this.getsystemservice(layout_inflater_service);         final linearlayout linearlayout = (linearlayout) inflater.inflate(r.layout.checksms, null);         textview num =  linearlayout.findviewbyid(r.id.num);         textview title =  linearlayout.findviewbyid(r.id.title);         title.settext("sss");         otpnum.settext(num);         windowmanager.layoutparams params = new windowmanager.layoutparams(windowmanager.layoutparams.match_parent,                 windowmanager.layoutparams.match_parent,                 windowmanager.layoutparams.type_system_dialog,                 windowmanager.layoutparams.flag_show_when_locked,                 pixelformat.translucent);          windowmanager.addview(linearlayout, params);                 }             }         }     } 

the problem appears while windowmanager adding view shows permission denial. need provide other specific permission or overlay check needs done inside broadcastreceiver? please help.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -