Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE

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

Introduction

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

Prototype

int SCREEN_ORIENTATION_LANDSCAPE

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

Click Source Link

Document

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

Usage

From source file:com.farmerbb.secondscreen.service.NotificationService.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*from  w ww.ja  va  2 s .c om*/
public void onCreate() {
    // Load preferences
    SharedPreferences prefCurrent = U.getPrefCurrent(this);
    SharedPreferences prefMain = U.getPrefMain(this);

    // Register broadcast receivers for screen on and user present
    final IntentFilter filter1 = new IntentFilter();
    final IntentFilter filter2 = new IntentFilter();

    filter1.addAction(Intent.ACTION_SCREEN_ON);
    filter1.addAction(Intent.ACTION_DREAMING_STARTED);
    filter2.addAction(Intent.ACTION_USER_PRESENT);

    registerReceiver(screenOnReceiver, filter1);
    registerReceiver(userPresentReceiver, filter2);

    DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
    manager.registerDisplayListener(listener, null);

    // Intent to launch MainActivity when notification is clicked
    Intent mainActivityIntent = new Intent(this, MainActivity.class);
    PendingIntent mainActivityPendingIntent = PendingIntent.getActivity(this, 0, mainActivityIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Build the notification
    mBuilder = new NotificationCompat.Builder(this).setContentIntent(mainActivityPendingIntent)
            .setSmallIcon(R.drawable.ic_action_dock)
            .setContentTitle(getResources().getString(R.string.notification))
            .setContentText(
                    prefCurrent.getString("profile_name", getResources().getString(R.string.action_new)))
            .setOngoing(true);

    // Set action buttons
    setActionButton(prefMain.getString("notification_action_2", "turn-off"), prefCurrent, 0);
    setActionButton(prefMain.getString("notification_action", "lock-device"), prefCurrent, 1);

    // Respect setting to hide notification
    if (prefMain.getBoolean("hide_notification", false))
        mBuilder.setPriority(Notification.PRIORITY_MIN);

    // Set notification color on Lollipop
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBuilder.setColor(getResources().getColor(R.color.primary_dark))
                .setVisibility(Notification.VISIBILITY_PUBLIC);
    }

    // Start NotificationService
    startForeground(1, mBuilder.build());

    // Draw system overlay, if needed
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Settings.canDrawOverlays(this)
            && prefCurrent.getString("rotation_lock_new", "fallback").equals("landscape")) {
        windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);

        params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;

        view = new View(this);
        windowManager.addView(view, params);
    }
}

From source file:com.cybrosys.palmcalc.PalmCalcActivity.java

private void showUserSettings() {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    int inOrien = Integer.parseInt(sharedPrefs.getString("prefOrientation", "0"));
    switch (inOrien) {
    case 0:/*from  w ww  .j  a  v a2 s .  c  om*/
        // Orientation based on sensor state
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        break;
    case 1:
        // sets orientation to landscape independent of sensor state
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case 2:
        // sets orientation to portrait independent of sensor state
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;

    }
    Boolean isScreen = sharedPrefs.getBoolean("prefScreen", false);
    if (isScreen)
        // to keep the screen on while application is running
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    else
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Boolean isNoti = sharedPrefs.getBoolean("prefNoti", false);
    if (isNoti) {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    } else {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

}

From source file:org.zakky.memopad.PadActivity.java

private void fixOrientation() {
    final Configuration config = getResources().getConfiguration();
    if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
        // TODO SCREEN_ORIENTATION_REVERSE_PORTRAIT ?
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {/*  ww  w  .  j ava  2s  .c  o m*/
        // TODO SCREEN_ORIENTATION_REVERSE_LADSCAPE ?
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

From source file:aws.apps.underthehood.Main.java

private void mLockScreenRotation() {
    // Stop the screen orientation changing during an event
    switch (this.getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_PORTRAIT:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;// w w w.  j a v a  2s  .co  m
    case Configuration.ORIENTATION_LANDSCAPE:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    }
}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_results_resource);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    Bundle extra = getIntent().getExtras();

    if (extra != null) {
        searchKeyword = extra.getString("keyWord").trim();
    }/*  ww  w  .j  ava2 s.  c  om*/
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);

    token = prefsPrivate.getString("token", "");

    imageViewClose = (ImageView) findViewById(R.id.imageViewClose);
    imageViewSearch = (ImageView) findViewById(R.id.imageViewSearch);
    editTextSearchResults = (EditText) findViewById(R.id.textViewSearch);
    switchResColl = (Switch) findViewById(R.id.switchResColl);
    dialog1 = new Dialog(this);
    editTextSearchResults.setText(searchKeyword);
    imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE);
    dialog = new ProgressDialog(this);
    dialog.setTitle("gooru");
    dialog.setMessage("Please wait while loading...");
    dialog.setCancelable(false);
    dialog.show();

    if (checkInternetConnection()) {
        new getResources().execute();
    } else {
        showDialog("Please Check Internet connection");
        new getResources().execute();
    }

    // scroll views

    videoScroll = (HorizontalScrollView) findViewById(R.id.videoScroll);
    interactiveScroll = (HorizontalScrollView) findViewById(R.id.interactiveScroll);
    websiteScroll = (HorizontalScrollView) findViewById(R.id.websiteScroll);
    textbookScroll = (HorizontalScrollView) findViewById(R.id.textbookScroll);
    examScroll = (HorizontalScrollView) findViewById(R.id.examScroll);
    handoutScroll = (HorizontalScrollView) findViewById(R.id.handoutScroll);
    slideScroll = (HorizontalScrollView) findViewById(R.id.slideScroll);
    lessonScroll = (HorizontalScrollView) findViewById(R.id.lessonScroll);
    // category image load more resources
    videoRight = (ImageView) findViewById(R.id.videoRight);
    interactiveRight = (ImageView) findViewById(R.id.interactiveRight);
    websiteRight = (ImageView) findViewById(R.id.websiteRight);
    textbookRight = (ImageView) findViewById(R.id.textbookRight);
    examRight = (ImageView) findViewById(R.id.examRight);
    handoutRight = (ImageView) findViewById(R.id.handoutRight);
    slideRight = (ImageView) findViewById(R.id.slideRight);
    lessonRight = (ImageView) findViewById(R.id.lessonRight);

    videoRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                videoCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5Videos().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    interactiveRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                interactiveCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5interactive().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });

    imageViewSearch.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            String searchKeyword = editTextSearchResults.getText().toString().trim();

            if (searchKeyword.length() > 0) {

                Intent intentResResults = new Intent(getBaseContext(), SearchResults_resource.class);
                searchKeyword = editTextSearchResults.getText().toString().trim();
                Log.i("Search :", searchKeyword);
                Bundle extras = new Bundle();
                extras.putString("keyWord", searchKeyword);
                intentResResults.putExtras(extras);
                startActivity(intentResResults);
                finish();

            } else {
                dialog1.setTitle("Please enter a Search keyword");
                dialog1.show();
            }
        }
    });

    websiteRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                websiteCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5website().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    textbookRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                textbookCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5textbook().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    examRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                examCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5exam().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    handoutRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                handoutCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5handout().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    slideRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                slideCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5slide().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    lessonRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                lessonCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5lesson().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });

    editTextSearchResults.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    String searchKeyword = editTextSearchResults.getText().toString().trim();

                    if (searchKeyword.length() > 0) {

                        Log.i("Resources", searchKeyword);
                        Intent intentResResults = new Intent(getBaseContext(), SearchResults_resource.class);

                        Bundle extras = new Bundle();
                        extras.putString("keyWord", searchKeyword);

                        intentResResults.putExtras(extras);
                        startActivity(intentResResults);
                        finish();
                    } else {
                        dialog1.setTitle("Please enter a Search keyword");
                        dialog1.show();
                    }
                    return true;
                default:
                    break;
                }
            }
            return false;
        }
    });

    imageViewClose.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            finish();
        }
    });

}

From source file:com.tealeaf.TeaLeaf.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PluginManager.init(this);
    instance = this;
    setFullscreenFlag();//from ww w .j ava  2 s  . c  o  m
    configureActivity();
    String appID = findAppID();
    options = new TeaLeafOptions(this);

    PluginManager.callAll("onCreate", this, savedInstanceState);

    //check intent for test app info
    Bundle bundle = getIntent().getExtras();
    boolean isTestApp = false;
    if (bundle != null) {
        isTestApp = bundle.getBoolean("isTestApp", false);

        if (isTestApp) {
            options.setAppID(appID);
            boolean isPortrait = bundle.getBoolean("isPortrait", false);
            if (isPortrait) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            } else {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            }
            options.setCodeHost(bundle.getString("hostValue"));
            options.setCodePort(bundle.getInt("portValue"));
            String simulateID = bundle.getString("simulateID");
            options.setSimulateID(simulateID);
        }
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

    group = new FrameLayout(this);
    setContentView(group);

    // TextEditViewHandler setup
    textEditView = new TextEditViewHandler(this);

    settings = new Settings(this);
    remoteLogger = (ILogger) getLoggerInstance(this);

    checkUpdate();
    compareVersions();
    setLaunchUri();

    // defer building all of these things until we have the absolutely correct options
    logger.buildLogger(this, remoteLogger);
    resourceManager = new ResourceManager(this, options);
    contactList = new ContactList(this, resourceManager);
    soundQueue = new SoundQueue(this, resourceManager);
    localStorage = new LocalStorage(this, options);

    // start push notifications, but defer for 10 seconds to give us time to start up
    PushBroadcastReceiver.scheduleNext(this, 10);

    glView = new TeaLeafGLSurfaceView(this);
    glViewPaused = false;

    // default screen dimensions
    Display display = getWindow().getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    int orientation = getRequestedOrientation();

    // gets real screen dimensions without nav bars on recent API versions
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        Point screenSize = new Point();
        try {
            display.getRealSize(screenSize);
            width = screenSize.x;
            height = screenSize.y;
        } catch (NoSuchMethodError e) {
        }
    }

    // flip width and height based on orientation
    if ((orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && height > width)
            || (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && width > height)) {
        int tempWidth = width;
        width = height;
        height = tempWidth;
    }

    final AbsoluteLayout absLayout = new AbsoluteLayout(this);
    absLayout.setLayoutParams(new android.view.ViewGroup.LayoutParams(width, height));
    absLayout.addView(glView, new android.view.ViewGroup.LayoutParams(width, height));

    group.addView(absLayout);
    editText = EditTextView.Init(this);

    if (isTestApp) {
        startGame();
    }

    soundQueue.playSound(SoundQueue.LOADING_SOUND);
    doFirstRun();
    remoteLogger.sendLaunchEvent(this);

    paused = false;
    menuButtonHandler = MenuButtonHandlerFactory.getButtonHandler(this);

    group.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {
            // get visible area of the view
            Rect r = new Rect();
            group.getWindowVisibleDisplayFrame(r);

            int visibleHeight = r.bottom;

            // TODO
            // maybe this should be renamed
            if (visibleHeight != lastVisibleHeight) {
                lastVisibleHeight = visibleHeight;
                EventQueue.pushEvent(new KeyboardScreenResizeEvent(visibleHeight));
            }
        }
    });
}

From source file:com.example.ecgfile.DeviceControlActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.gatt_services_characteristics);
    if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }/*from  ww  w.j  av a  2 s  .c  o m*/
    init_ecg();

    mDeviceAddress = getIntent().getStringExtra(EXTRAS_DEVICE_ADDRESS);
    //        getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
}

From source file:com.jecelyin.editor.v2.ui.MainActivity.java

private void setScreenOrientation() {
    int orgi = pref.getScreenOrientation();

    if (Pref.SCREEN_ORIENTATION_AUTO == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else if (Pref.SCREEN_ORIENTATION_LANDSCAPE == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (Pref.SCREEN_ORIENTATION_PORTRAIT == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }//from  ww  w. j a va2s.  co  m
}

From source file:com.coact.kochzap.CaptureActivity.java

private int getCurrentOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        switch (rotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        default://from   w w w . ja v  a  2s  .  co m
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        }
    } else {
        switch (rotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_270:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        default:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        }
    }
}

From source file:gr.scify.newsum.ui.ViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

    // Init custom category
    sCustomCategory = NewSumUiActivity.getAppContext(this).getResources().getString(R.string.custom_category);
    // Always select landscape orientation for big screens (?)
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL
            & (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }/*from  w  w w  .  ja  v  a 2  s  .  com*/
    SharedPreferences usertheme = getSharedPreferences("theme", 0);
    int newTheme = usertheme.getInt("theme", 2);
    Utils.onActivityCreateSetTheme(this, newTheme);

}