-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivityHelper.java
More file actions
21 lines (18 loc) · 862 Bytes
/
ActivityHelper.java
File metadata and controls
21 lines (18 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.example.controller;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.preference.PreferenceManager;
public class ActivityHelper {
public static void initialize(Activity activity) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
String orientation = prefs.getString("prefOrientation", "Null");
if ("Landscape".equals(orientation)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else if ("Portrait".equals(orientation)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
}
}
}