Is this a new version in Android 4.0?

I developed the application in android 4.0.3 (Ice-cream Sandwich), I use two actions to check the navigation of actions. But I observed a different behavior in the navigation of actions.

I call Activity B from Activity A. In Activity B, I just call the finish () method. So that we can see the previous activity A. It works exactly as expected, but the problem is the reverse movement (the method of ending the call or pressing the back key), it calls the WithCreate () method of Activity A instead of calling onResume (). But in previous versions this is not so. Is this a new version in android 4.0?

Here is an example that I implemented:

Activity_A:

public class Activity_A extends Activity {

    /** Called when the activity is first created. */
    static int count=0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView text=(TextView)findViewById(R.id.textcontent);
        text.setText("Activity 1 called:"+(++count)+" Times");
    }

    public void onClick(View v)
    {
        Intent intent=new Intent(this,Activity2.class);
        startActivityForResult(intent, 1);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d("onActivityResult", "Called with Code:"+resultCode);
    }

}

Activity_B:

public class Activity_B extends Activity {

      /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView text=(TextView)findViewById(R.id.textcontent);
        text.setText("Activity 2");
    }

    public void onClick(View v)
    {
        setResult(1);
        finish();
    }
}

Please check and let me know if I am wrong.

Thanks Ram.

+5
4

Android ( ):

  • ( ) .
  • , ( , ), . ( ), .
  • , . - , , , , .
  • , , . , .

, 3 4 .

+1

!! // " "

+7

onSavedInstanceState() onRestoreInstanceSate().

0

: fooobar.com/questions/88934/.... :

A ( ) : android:launchMode="singleTop" AndroidManifest.xml. , Android , The system always creates a new instance of the activity in the target task., ( Android).

singleTop ( ), .

0

All Articles