Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED

List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED

Introduction

In this page you can find the example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED.

Prototype

int SCREEN_ORIENTATION_UNSPECIFIED

To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED.

Click Source Link

Document

Constant corresponding to unspecified in the android.R.attr#screenOrientation attribute.

Usage

From source file:org.uoyabause.android.tv.GameSelectActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    boolean lock_landscape = sharedPref.getBoolean("pref_landscape", false);
    if (lock_landscape == true) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {// w  ww .  ja va 2 s. c  o m
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }

    super.onCreate(savedInstanceState);

    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int resultCode = googleAPI.isGooglePlayServicesAvailable(this);

    if (resultCode != ConnectionResult.SUCCESS) {
        Log.e(TAG, "This device is not supported.");
    }

    Log.d(TAG, "InstanceID token: " + FirebaseInstanceId.getInstance().getToken());

    setContentView(R.layout.activity_game_select);
}

From source file:com.waz.zclient.utils.ViewUtils.java

public static void unlockOrientation(Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}

From source file:com.glacialsoftware.googolplex.GoogolplexDisplayActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    String theme = PreferenceManager.getDefaultSharedPreferences(this).getString("theme_select", "Light");
    if (theme.equals("Light")) {
        setTheme(R.style.lightTheme);//from www .j a v  a2 s. c om
        currentTheme = theme;
    } else {
        setTheme(R.style.darkTheme);
        currentTheme = theme;
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_googolplex_display);
    //created=true;

    if (savedInstanceState == null) {
        Intent intent = getIntent();
        savedInstanceState = intent.getBundleExtra("com.glacialsoftware.googolplex.manualSavedInstanceState");
    }

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("tilt_lock", false)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }

    firstVisiblePosition = 0;
    overlayShowing = false;
    preferencesShowing = false;
    int overlayPosition = 0;
    if (savedInstanceState != null) {
        firstVisiblePosition = savedInstanceState.getInt("firstVisiblePosition");
        overlayShowing = savedInstanceState.getBoolean("overlayShowing");
        overlayPosition = savedInstanceState.getInt("overlayPosition");
        preferencesShowing = savedInstanceState.getBoolean("preferencesShowing");
    }

    googolplexDisplayFragment = new GoogolplexDisplayFragment(overlayShowing, overlayPosition);
    digitOverlayFragment = new DigitOverlayFragment();
    googolplexPreferenceFragment = new GoogolplexPreferenceFragment();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.add(R.id.googolplex_display_frame, googolplexDisplayFragment);
    fragmentTransaction.add(R.id.googolplex_display_frame, digitOverlayFragment);
    fragmentTransaction.add(R.id.googolplex_display_frame, googolplexPreferenceFragment);
    fragmentTransaction.hide(digitOverlayFragment);
    fragmentTransaction.hide(googolplexPreferenceFragment);
    fragmentTransaction.commit();
}

From source file:cordova.plugins.screenorientation.CDVOrientation.java

private boolean routeScreenOrientation(JSONArray args, CallbackContext callbackContext) {

    String action = args.optString(0);

    String orientation = args.optString(1);

    Log.d(TAG, "Requested ScreenOrientation: " + orientation);

    Activity activity = cordova.getActivity();

    if (orientation.equals(ANY)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else if (orientation.equals(LANDSCAPE_PRIMARY)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (orientation.equals(PORTRAIT_PRIMARY)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (orientation.equals(LANDSCAPE)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else if (orientation.equals(PORTRAIT)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    } else if (orientation.equals(LANDSCAPE_SECONDARY)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
    } else if (orientation.equals(PORTRAIT_SECONDARY)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
    }// w  ww  .  jav a2 s.c  o m

    callbackContext.success();
    return true;

}

From source file:net.yoik.cordova.plugins.screenorientation.YoikScreenOrientation.java

private boolean routeScreenOrientation(JSONArray args, CallbackContext callbackContext) {

    String action = args.optString(0);

    if (action.equals("set")) {

        String orientation = args.optString(1);

        Log.d(TAG, "Requested ScreenOrientation: " + orientation);

        Activity activity = cordova.getActivity();

        if (orientation.equals(UNLOCKED)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else if (orientation.equals(LANDSCAPE_PRIMARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT_PRIMARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else if (orientation.equals(LANDSCAPE)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
        } else if (orientation.equals(LANDSCAPE_SECONDARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT_SECONDARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        }//from w  ww  .j ava 2  s  .  c om

        callbackContext.success();
        return true;

    } else {
        callbackContext.error("ScreenOrientation not recognised");
        return false;
    }
}

From source file:org.xwalk.runtime.extension.api.screenorientation.ScreenOrientationExtension.java

@Override
public void onMessage(int instanceId, String message) {
    String value = getValueString(message, JS_VALUE_TYPE);
    if (value.isEmpty())
        return;/*from w  w w.  ja  va  2s  .c  om*/

    int orientation;
    try {
        orientation = Integer.valueOf(value);
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    int screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    switch (orientation) {
    case ANY:
    case UA_DEFAULTS: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        break;
    }
    case LANDSCAPE_PRIMARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        break;
    }
    case PORTRAIT_PRIMARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        break;
    }
    case LANDSCAPE_SECONDARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        break;
    }
    case PORTRAIT_SECONDARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        break;
    }
    case LANDSCAPE: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
        break;
    }
    case PORTRAIT: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
        break;
    }
    default:
        Log.e(TAG, "Invalid orientation value.");
        return;
    }
    mExtensionContext.getActivity().setRequestedOrientation(screen_orientation_value);
}

From source file:com.coinblesk.client.SendPaymentFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = super.onCreateView(inflater, container, savedInstanceState);
    assert view != null;

    final ProgressDialog dialog = new ProgressDialog(this.getActivity());
    dialog.setMessage(getString(R.string.fragment_send_dialog_scanning));
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override//from  w w  w.j a  v a2s . c om
        public void onShow(DialogInterface dialog) {
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
        }
    });
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
            LocalBroadcastManager.getInstance(getActivity())
                    .sendBroadcast(new Intent(Constants.STOP_CLIENTS_ACTION));
        }
    });

    /*view.setOnTouchListener(new View.OnTouchListener() {
    private float startPoint = 0;
            
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        float heightValue = event.getY();
        switch (MotionEventCompat.getActionMasked(event)) {
            case (MotionEvent.ACTION_DOWN):
                startPoint = heightValue;
                return true;
            case (MotionEvent.ACTION_MOVE):
            
                if (heightValue - startPoint > THRESHOLD) {
                    if (!dialog.isShowing()) {
                        dialog.show();
                        IntentFilter instantPaymentFinishedIntentFilter = new IntentFilter(Constants.INSTANT_PAYMENT_FAILED_ACTION);
                        instantPaymentFinishedIntentFilter.addAction(Constants.INSTANT_PAYMENT_SUCCESSFUL_ACTION);
            
                        LocalBroadcastManager
                                .getInstance(getContext())
                                .registerReceiver(new BroadcastReceiver() {
                                    @Override
                                    public void onReceive(Context context, Intent intent) {
                                        LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(this);
                                        dialog.dismiss();
                                    }
                                 }, instantPaymentFinishedIntentFilter);
                        LocalBroadcastManager
                                .getInstance(getContext())
                                .sendBroadcast(new Intent(Constants.START_CLIENTS_ACTION));
                    }
                }
                break;
        }
        return false;
    }
    });*/

    return view;
}

From source file:com.waz.zclient.utils.ViewUtils.java

public static void lockScreenOrientation(int orientation, Activity activity) {
    switch (orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;// ww w.  j av a2s  .com
    case Configuration.ORIENTATION_LANDSCAPE:
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    default:
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        break;
    }
}

From source file:ru.neverdark.phototools.DetailsActivity.java

/**
 * Shows fragment by index delivered from MainActivity
 */// w w w.j  a  va  2  s  . c  om
private void showFragment() {
    Log.message("Enter");
    int index = getIntent().getIntExtra(Constants.SHOWN_INDEX, 0);
    Log.variable("index", String.valueOf(index));
    switch (index) {
    case Constants.DOF_CHOICE:
        DofFragment dofFragment = new DofFragment();
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, dofFragment).commit();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case Constants.EV_CHOICE:
        EvpairsFragment evFragment = new EvpairsFragment();
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, evFragment).commit();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case Constants.SUNSET_CHOICE:
        SunsetFragment sunsetFragment = new SunsetFragment();
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, sunsetFragment).commit();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        break;
    case Constants.ABOUT_CHOICE:
        AboutFragment aboutFragment = new AboutFragment();
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, aboutFragment).commit();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        break;
    case Constants.PLUGIN_CHOICE:
        PluginsFragment pluginFragment = new PluginsFragment();
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, pluginFragment).commit();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        break;
    }

}

From source file:de.limexcomputer.cordova.plugin.rotationlock.RotationLock.java

/**
 * Executes the request./* www.  java 2 s .c  om*/
 *
 * This method is called from the WebView thread.
 * To do a non-trivial amount of work, use:
 *     cordova.getThreadPool().execute(runnable);
 *
 * To run on the UI thread, use:
 *     cordova.getActivity().runOnUiThread(runnable);
 *
 * @param action   The action to execute.
 * @param args     The exec() arguments in JSON form.
 * @param callback The callback context used when calling back into JavaScript.
 * @return         Whether the action was valid.
 */
@Override
public boolean execute(String action, JSONArray args, CallbackContext callback) throws JSONException {

    if (!action.equalsIgnoreCase("setOrientation")) {
        return false;
    }

    String orientation = args.optString(0);

    Activity activity = this.cordova.getActivity();

    // refer to https://github.com/their/pg-plugin-screen-orientation/blob/master/src/ScreenOrientation.java

    if (orientation.equals(UNSPECIFIED)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else if (orientation.equals(LANDSCAPE)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (orientation.equals(PORTRAIT)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (orientation.equals(USER)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
    } else if (orientation.equals(BEHIND)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_BEHIND);
    } else if (orientation.equals(SENSOR)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    } else if (orientation.equals(NOSENSOR)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    } else if (orientation.equals(SENSOR_LANDSCAPE)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else if (orientation.equals(SENSOR_PORTRAIT)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    } else if (orientation.equals(REVERSE_LANDSCAPE)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
    } else if (orientation.equals(REVERSE_PORTRAIT)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
    } else if (orientation.equals(FULL_SENSOR)) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
    }

    callback.success(orientation);
    return true;
}