开发者

killing calling activity from child activity android

开发者 https://www.devze.com 2023-03-29 23:25 出处:网络
suppose app is started with activity A then from A call to B.then B to C then C to D.after starting D if us开发者_如何学运维er presses Home Key then again start app from launcheri want to start the ap

suppose app is started with activity A then from A call to B.then B to C then C to D.after starting D if us开发者_如何学运维er presses Home Key then again start app from launcheri want to start the app from activity A and if on B activity user presses back button app should close.Activity A should not b called..


Its simple if U want to call an activity you can use Intent. check the code

  Button button1 = (Button)findViewById(R.id.mybtn);
 button1.setOnClickListener(new OnClickListener() {

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

         finish();


    }
});  

Here RegisterActivity.class is the activity which u want to call


As I understand you don't want to go back to Activity A again. In that case you need to clear the activity from history stack. While declaring activity in Manifest file set noHistory to true. see below.

<activity android:name=".A"
    android:noHistory="true"/> 

Hope this helps.

0

精彩评论

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