Skip to content

Instantly share code, notes, and snippets.

@keinix
Created July 21, 2017 00:06
Show Gist options
  • Save keinix/b1a6af47e46cdcfed4524888b5de39be to your computer and use it in GitHub Desktop.
Save keinix/b1a6af47e46cdcfed4524888b5de39be to your computer and use it in GitHub Desktop.
Turn the entire android app to portrait only.
package com.keinix.interactivestory;
import android.app.Activity;
import android.app.Application;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
public class InteractiveStoryApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
}
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment