Saturday, March 5, 2016

Android : Setting Landscape or Portrait Only Orientation

Posted by with No comments

Landscape only:

in AndroidManifest.xml
//in activity tag
android:screenOrientation="landscape"
in code
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)

Portrait only:

in AndroidManifest.xml
//in activity tag
android:screenOrientation="portrait"
in code
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)

Android : Remove Previous Activity From Stack After Intent

Posted by with No comments
Intent intent = new Intent(InitialActivity.this, MainActivity.class); 
InitialActivity.this.startActivity(intent); 
finish();