chat - Foreground method is not working in Jellybean in Android -


i have implemented service chat application , concept should online , last seen whatsapp.

when implemented online , last seen service app , when checked lollipop lollipop working 100% fine when checked same thing jellybean lollipop not working more.

@override     protected void onstop() {         super.onstop();          if (utils.isappsenttobackground(getapplicationcontext())) {              // call web service here             // log.e("angel", "in back");             utils.setinbackground(getapplicationcontext(), true);             callonlineofflineservice("0");         }     }   // code resume called     @override     protected void onresume() {         super.onresume();         setrequestedorientation(activityinfo.screen_orientation_portrait);          if (utils.isinbackground(getapplicationcontext())) {             // log.e("angel", "from back");              utils.setinbackground(getapplicationcontext(), false);             callonlineofflineservice("1");         }     } 

here, util common class in have implemented common method , setinbackground method set credentials sessionmanager.

void callonlineofflineservice(string status) {          log.e("status:::::online", "status" +status);          if(!myclass.isconnected(getapplicationcontext())){             errordialog(getresources().getstring(r.string.no_internet));             return;         }          final list<namevaluepair> params = new arraylist<namevaluepair>();         params.add(new basicnamevaluepair("mode", "setuseronlinestatus"));         params.add(new basicnamevaluepair("userid", uid));         params.add(new basicnamevaluepair("status", status));          log.e("status:::::online", "status" +params);              runnable runnable = new runnable() {                 public void run() {                       userfunctions userfunction = new userfunctions(getapplicationcontext());                     jsonobject json = userfunction.commonobject(params);                          try {                              final string s = json.getstring("status");                             log.e("status:::::online", "status" +s);                          } catch (jsonexception e) {                             e.printstacktrace();                              return;                         }                 }             };             thread mythread = new thread(runnable);             mythread.start();     } 

your hard work , efforts highly appreciated , in advance.

i have tried , came conclusion , works.

just make sure, have given below permission, after above code working fine otherwise not working os.

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

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -