android - Close Application if no internet connection -


oncreate of "home" activity, want check if there's internet connection, if false close activity showing toast..
but, home activity not first on stack, if set finish(); close activity , show top 1 in activity stack..
so i've written down code, make sense?

 if(!utils.isonline(mcontext))         if(!movetasktoback(true))             finish(); 

where utils.isonline() method check internet connection

edit: i've created method check internet connection , it's utils.isonline().. i'm not asking how check internet connectio...

edit2: movetasktoback() not best choice achieve target, because yes puts activity onbackground if reopen it, app doesn't check anymore condition (don't know why.. skips oncreate(?)) , shows blank activity..

if want close app can add lines:

intent intent = new intent(intent.action_main);        intent.addcategory(intent.category_home);        intent.setflags(intent.flag_activity_new_task);         startactivity(intent); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -