java - How to create and start a dream service atomatically android -


i trying start dream service. currently, code:

@suppresslint("newapi") public class dreamlockservice extends dreamservice {      private static final string tag = "dreamlockservice";     public utility utilobj = new utility();      //private button btnexit;      private button btnlogin;     private edittext lgpass;      @override     public void onattachedtowindow() {         super.onattachedtowindow();         // exit dream upon user touch         setinteractive(true);         // hide system ui         setfullscreen(true);         // set dream layout         setcontentview(r.layout.lockservice);         //setclicklistener();         toast.maketext(this, "lock service created", toast.length_long).show();     }      //use initial setup, such calling setcontentview().     @override     public void ondreamingstarted() {         super.ondreamingstarted();         // exit dream upon user touch         setinteractive(true);         // hide system ui         setfullscreen(true);         // set dream layout         setcontentview(r.layout.lockservice);         toast.maketext(this, "lock service created", toast.length_long).show();     }      //your dream has started, should begin animations or other behaviors here.     public void ondreamingstopped()     {         super.ondreamingstopped();     }      //use stop things started in ondreamingstarted().     public void ondetachedfromwindow()     {         super.ondetachedfromwindow();     } } 

i unable start dream service activity. used:

intent templock = new intent(mainactivity.this, dreamlockservice.class); //dreamlockservice test = new dreamlockservice(); startservice(templock); 

i don't understand why didn't work. how can dream service started activity?

to start dream service our own app, please try this.

    ibinder binder = servicemanager.getservice("dreams");      parcel data = parcel.obtain();     data.writeinterfacetoken("android.service.dreams.idreammanager");     parcel reply = parcel.obtain();     try {         if (binder != null)             binder.transact(1, data,reply, binder.flag_oneway);         else             log.e("tag", "dreams service not running");     } catch (remoteexception e) {         e.printstacktrace(); }  

to use this, app should system app , should have dream permissions in manifest file , enable dream setting in settings.

i tried , working.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -