开发者

Click "Exit" button through our Application It need to go Phones's Home page & remove SharedPreferences also

开发者 https://www.devze.com 2023-03-29 11:40 出处:网络
My question is when I click the \"Exit\" button through our application It need to go to Phones\'s Home screen.I have Tried like this

My question is when I click the "Exit" button through our application It need to go to Phones's Home screen.I have Tried like this

  public void onExitAction(View botton){
          // finish();
          // super.finish();
           // System.runFinalizersOnExit(true)

       开发者_开发问答     //android.os.Process.killProcess(android.os.Process.myPid());

     System.exit(0);

}

Not working.

When I put finish() its closing that particular activity & its go to previous screen.

seconds one is When we exit the system need to remove SharedPreferences also?

Please help me on this...

Thanks in advance


    public void onExitAction(View botton){       
    Intent startMain = new Intent(Intent.ACTION_MAIN);
    startMain.addCategory(Intent.CATEGORY_HOME);
    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(startMain);
    finish();       
    }


use

    moveTaskToBack(true);

for your exit button. Though it will not kill the application.it will just move the application to background and displays the Home screen


Try this,

 logbackbtn.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        //Intent myIntent = new Intent(v.getContext(),
        //      MyTestglobe.class);
        //startActivityForResult(myIntent, 0);
        finish();
    }
});


try this,

Intent myIntent = new Intent(view.getContext(), firstActivity.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(myIntent);
finish();
0

精彩评论

暂无评论...
验证码 换一张
取 消