Procedure to ignore Screen Orientations(means to restrict Activity to not destroy and reCreate activity for every orientation change),in Android

add a couple of attributes in your manifest file 
        <activity  android:name=".blah" 
android:screenOrientation="portrait" 
        android:configChanges="orientation|keyboardHidden" /> 
and then override a method 
    @Override 
    public void onConfigurationChanged(Configuration newConfig) { 
      //ignore orientation change 
      super.onConfigurationChanged(newConfig); 
    } 
to ignore any orientation change. 

----------------------------------------OR--------------------------------


@Override
    public void onConfigurationChanged(Configuration newConfig) {
     super.onConfigurationChanged(newConfig);
     setContentView(R.layout.main);
     
     SetupActivity();
    }
    
    private void SetupActivity() {
     itemView = (ToDoItemView)findViewById(R.id.cstNote);
        itemView.setOnTouchListener(myTouch);
        
        if (points != null)
         itemView.setPoints(points);
        
        text = (EditText)findViewById(R.id.txtText);
        txtX = (EditText)findViewById(R.id.txtX);
        txtY = (EditText)findViewById(R.id.txtY);
        
        text.setOnKeyListener(myListener);        
        txtX.setOnKeyListener(myListener);        
        txtY.setOnKeyListener(myListener);
    }

Comments

Popular posts from this blog

Custom Dialog with no title and full screen in Android

Best working code to set Date limits on Date Picker Dialog,in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard