Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android intent reception and rotation

I'm using an Intent Filter in my activity to retrive an url clicked on by the user.

In my activity onCreate method I have the following code

    Intent intent = getIntent();
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        url = intent.getDataString();
        showDialog(DIALOG_ID);          
    }

It works great except when I rotate my phone. Even if tha dialog was closed prior to the rotation, it reopen every time I change the phone orientation. I can I avoir that.

For your information I don't want to lock the orientation

like image 864
user1026605 Avatar asked Dec 27 '22 23:12

user1026605


1 Answers

Another solution that doesn't require handling configuration changes yourself might be to simply check if the savedInstanceState Bundle parameter in onCreate is null before showing the dialog.

If you look at the docs for onCreate you can see that savedInstanceState will be non-null when the activity is recreated (due to configuration changes for example) and thus will be null when the activity is run fresh.

like image 128
satur9nine Avatar answered Dec 31 '22 14:12

satur9nine