Thursday, 20 March 2014

How to exit application without close application in android;

It happen many times that you don’t want to finish the activity you just want your application will work in the background and when any user click than it will go to the home page but the application should be running;

Use the below code it will exit you from application but it won’t close the application in android

//Code to exit from apllication
    public void ExitApp()
       {
              Intent intent = new Intent(Intent.ACTION_MAIN);
              intent.addCategory(Intent.CATEGORY_HOME);
              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              startActivity(intent);
             
              backgroundSound.stop();
              //setDetectEnabled(false);
             

       }

No comments:

Post a Comment