I use setTitle to change the activity label on runtime. But every time when rotating the phone, the activity label changes back to its initial state. How can I prevent this?
            Asked
            
        
        
            Active
            
        
            Viewed 99 times
        
    1
            
            
         
    
    
        Fihop
        
- 3,127
- 9
- 42
- 65
- 
                    when the orientation changes your activity restarts in usual case.. do you wanto prevent it from restarting? – stinepike Apr 18 '13 at 01:19
2 Answers
1
            write the following in your activity declaration in manifest file
android:configChanges="orientation"
It will prevent your activity to be restarted when orientation is changed.
EDIT:
From this so answer it suggested to use the following for newer api
android:configChanges="keyboardHidden|orientation|screenSize"
1
            
            
        You can save and restore your state of Activity using onSaveInstanceState() and onRestoreInstanceState().
Preventing orientation change is also a good method, but i'd like to recommend to use these functions for more flexibility to your application.
For more information, you can see this Link
 
    
    
        Community
        
- 1
- 1
 
    
    
        Nari Kim Shin
        
- 2,459
- 1
- 25
- 33
