android service not starting or giving explict error -


i have service check screen on of. calling service activity mentioned below. when call service in device below lollipop works. working lollipop also. stopped working on lollipop , gives me error java.lang.illegalargumentexception: service intent must explicit no tried various methods , not able understand whats happening.....

package com.androidexample.screenonoff;  import android.app.activity; import android.app.alertdialog; import android.app.service; import android.content.broadcastreceiver; import android.content.context; import android.content.dialoginterface; import android.content.intent; import android.content.intentfilter; import android.os.ibinder; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.imageview; import android.widget.textview; import android.widget.toast;   public class aescreenonoffservice extends service  {     broadcastreceiver mreceiver=null;          @override         public void oncreate() {             super.oncreate();              // toast.maketext(getbasecontext(), "service on create", toast.length_short).show();              // register receiver handles screen on , screen off logic             intentfilter filter = new intentfilter(intent.action_screen_on);             filter.addaction(intent.action_screen_off);             mreceiver = new aescreenonoffreceiver();             registerreceiver(mreceiver, filter);          }          @override         public void onstart(intent intent, int startid) {               boolean screenon = false;              try{                 // on/off values sent receiver ( aescreenonoffreceiver.java )                  screenon = intent.getbooleanextra("screen_state", false);              }catch(exception e){}               //  toast.maketext(getbasecontext(), "service on start :"+screenon,                      //toast.length_short).show();              if (!screenon) {                  // code here                 // time required start service                 //toast.maketext(getbasecontext(), "begin ", toast.length_long).show();                 //  intent yourintent = new intent(this, postlockscreen.class);                 //yourintent.addflags(intent.flag_activity_new_task);                 //startactivity(yourintent);               } else {                  // code here                 // time required stop service save battery consumption                 //toast.maketext(getbasecontext(), "screen off,", toast.length_long).show();                 intent yourintent = new intent(this, postlockscreen.class);                 yourintent.addflags(intent.flag_activity_new_task);                 startactivity(yourintent);             }         }          @override         public ibinder onbind(intent intent) {             // todo auto-generated method stub             return null;         }  } 

no when start service device lesser lollipop starts service , works fine

package com.androidexample.screenonoff;  import android.os.bundle; import android.app.activity; import android.content.intent;  public class screenonoff extends activity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_screen_on_off);          // start aescreenonoffservice service          intent i0 = new intent();         i0.setaction("com.androidexample.screenonoff.aescreenonoffservice");         startservice(i0);         //startservice(new intent(this, aescreenonoffservice.class));      }    } 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -