Android coding which used in Every Project

Sep 30, 2015
299 Views
You're android developer - beginner or pro doesn't matter because below any of 13 android code you'll use in your most of project.So read it and bookmark it for faster development in Android.
Mostly used android coding, Commonly, Frequently and Daily used Android coding

How to Disable Home Button

@Override  
public void onAttachedToWindow()  
{    
    this.getWindow().setType(WindowManager.  
      LayoutParams.TYPE_KEYGUARD_DIALOG);       
    super.onAttachedToWindow();    
}  

How to Disable Back Button

@Override  
public boolean onKeyDown(int keyCode, KeyEvent event) {  
    return false;  
} 

How to Disable Soft Keypad

final EditText txtName = (EditText) findViewById(R.id.txtName);  
txtName.setInputType(InputType.TYPE_NULL);  

How to Make Static Rotation/orientation in Android

//if you want to lock screen for always Portrait mode  
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);  
                             or  
//if you want to lock screen for always Landscape mode  
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

If you've any other code which you use frequently in your coding then comment me. I'll add in this list.

For full article go to : 

Mostly used android coding

Comments
avatar
Please sign in to add comment.