You're doing a lot of stuff just to kill the app off before anything can happen. This just seems like a hacky solution. Why don't you just do it properly and handle the exception by telling the user that the connection died (via a toast, something in the UI, or a notification) and ask them if they want to try again. This is what basically every app does. I don't know about most users, but I would find it pretty cheap if an app just said "the internet isn't connected, I'm quitting" before anything in the app happened.
kris On Thu, Feb 23, 2012 at 5:11 AM, Muhammad UMER <[email protected]> wrote: > hi, > I have done something like this on the onCreate() method. when the > activity created it first check the network availability if not then show > dialog and the finish the application. Is it true approch? > > > if(isNetworkAvailable()!= true) > { > AlertDialog ad = new AlertDialog.Builder(this).create(); > ad.setCancelable(false); // This blocks the 'BACK' button > ad.setMessage("Network connection is not available"); > ad.setButton("OK", new DialogInterface.OnClickListener() { > @Override > public void onClick(DialogInterface dialog, int which) { > dialog.dismiss(); > finish(); //// exit the programe > } > }); > ad.show(); > > } > > Thanks > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

