How to kill whole application in onne single click.. finish() is not working?? it redirects to tha previous activity...pls guide me.
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            WallpaperManager wp = WallpaperManager
                    .getInstance(getApplicationContext());
            try {
                Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
                        .getDefaultDisplay();
                int width = d.getWidth();
                int height = d.getHeight();
                wp.setBitmap(b1);
            } catch (IOException e) {
                Log.e("error", "Cannot set image as wallpaper", e);
            }
                        finish();
        }
                System.exit() does not kill your app if you have more than one activity on the stack
Use android.os.Process.killProcess(android.os.Process.myPid()); this way.
for sample
public void onBackPressed() {
    android.os.Process.killProcess(android.os.Process.myPid());
    super.onBackPressed();
}
For more detail see Is quitting an application frowned upon? , How to force stop my android application programmatically?
I hope this will help you.
You can use this function to close your application
Process.killProcess( Process.myPid() ); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With