android - startLockTask() is not working in oppo phones -


i implemented startlocktask() screen pinning using below code. when application opened request screen pinning. if user accept screen app pinned. in oppo phones first have turn on pinning , manually pin application. different procedures in different phones. there unique way app pinning. need show permission pinning in devices above android 5.0 , if user accepts app pinned

import android.app.activitymanager; import android.app.admin.devicepolicymanager; import android.content.componentname; import android.content.context; import android.content.intent; import android.os.build; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.textview;  public class mainactivity extends appcompatactivity {     string tag="valuees";     textview text;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         text=(textview)findviewbyid(r.id.text);         final devicepolicymanager mdpm = (devicepolicymanager) getsystemservice(context.device_policy_service);         final componentname mdeviceadminsample = new componentname(this, mainactivity.class);         startlocktask();         text.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 boolean val=isappinlocktaskmode();                 log.d("lockstate",val.tostring());             }         });     }     public boolean isappinlocktaskmode() {         activitymanager activitymanager;          activitymanager = (activitymanager)                 this.getsystemservice(context.activity_service);          if (build.version.sdk_int >= build.version_codes.m) {             // sdk version 23 , above.             return activitymanager.getlocktaskmodestate()                     != activitymanager.lock_task_mode_none;         }          if (build.version.sdk_int >= build.version_codes.lollipop) {             // when sdk version >= 21. api deprecated in 23.             return activitymanager.isinlocktaskmode();         }          return false;     } } 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -