Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a New Implementation in Android 4.0?

I have developed an app in android 4.0.3(Ice-cream Sandwich), i am using two activities to test the activity navigation.But i Observed a different behavior in Activity navigation.

I am calling Activity B From Activity A. In Activity B i am just calling the finish() method. So that we can see the Previous Activity A. It is exactly working as expected but the problem is for back navigation(Calling finish method or pressing back-key),it is calling onCreate() Method of Activity A instead of calling the onResume(). But in previous versions it is not behaving like this. Is this a new Implementation in android 4.0??

Here is the example which 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 doing any mistake.

Thanks, Ram.

like image 784
ram Avatar asked Dec 23 '11 14:12

ram


People also ask

Can Android 4.0 be updated?

Android always comes up with upgraded versions, and you must know how to upgrade Android 4.0. 4 to the latest version. Follow the below steps to update your phone: For your smartphone to work, you'll need to connect to the internet over Wi-Fi.

What is the current newest Android version?

Android 12 is designed for your safety. With new easy-to-use, powerful privacy features, you'll have peace of mind knowing that you have control over who can see your data and when.

Does Google still support Android 4?

Final version: 4.0. 4; released on March 29, 2012. Initial version: Released on October 18, 2011. Google no longer supports Android 4.0 Ice Cream Sandwich.


1 Answers

I have the same problem!! Go to Settings/Development/ and uncheck 'Destroy Activities'

like image 70
lorbios Avatar answered Sep 20 '22 11:09

lorbios