Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT

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

Introduction

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

Prototype

int SCREEN_ORIENTATION_PORTRAIT

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

Click Source Link

Document

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

Usage

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://  w  w  w  . ja  v a  2 s  . co  m
        // 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:com.fvd.nimbus.MainActivity.java

boolean isTablet() {
    /*Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    Point size = new Point();/*from  w w  w .  j  a v a 2  s  .  c  o  m*/
    size.x = d.getWidth();
    size.y = d.getHeight();*/
    //boolean b = size.x>1280 || size.y>1280;//size.x>480 && size.y>800||size.x>800 && size.y>480;
    boolean b = getResources().getInteger(R.integer.is_tablet) != 0;
    //boolean b=(this.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)>= Configuration.SCREENLAYOUT_SIZE_LARGE;
    if (!b)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    return b;
}

From source file:com.tealeaf.TeaLeaf.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PluginManager.init(this);
    instance = this;
    setFullscreenFlag();//  w  ww.  j ava 2s . c  om
    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.google.sample.cast.refplayer.Synchronization.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    //setImmersiveMode();
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.synchronization);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        UserIndex = Integer.parseInt(extras.getString("UserIndex"));
        Log.d(TAG, "UserIndex: " + UserIndex);
    }// ww w . j a v  a  2s . co  m

    initUI();
    setMediaRouter();
    getVideoURL();
    buildSocketConnection();

}

From source file:me.drakeet.meizhi.ui.GankFragment.java

@Subscribe
public void onKeyBackClick(OnKeyBackClickEvent event) {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }/*from  ww w.  jav  a 2 s. co m*/
    clearVideoView();
}

From source file:com.cypress.cysmart.HomePageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isTablet(this)) {
        Logger.d("tablet");
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else {//from  w w w.  jav  a2s.co m
        Logger.d("Phone");
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    setContentView(R.layout.activity_main);
    Paired = getResources().getString(R.string.bluetooth_pair);
    Unpaired = getResources().getString(R.string.bluetooth_unpair);
    parentView = (DrawerLayout) findViewById(R.id.drawer_layout);
    containerView = (FrameLayout) findViewById(R.id.container);
    mpdia = new ProgressDialog(this);
    mpdia.setCancelable(false);
    mAlert = new AlertDialog.Builder(this).create();
    mAlert.setMessage(getResources().getString(R.string.alert_message_bluetooth_reconnect));
    mAlert.setCancelable(false);
    mAlert.setTitle(getResources().getString(R.string.app_name));
    mAlert.setButton(Dialog.BUTTON_POSITIVE, getResources().getString(R.string.alert_message_exit_ok),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent intentActivity = getIntent();
                    finish();
                    overridePendingTransition(R.anim.slide_left, R.anim.push_left);
                    startActivity(intentActivity);
                    overridePendingTransition(R.anim.slide_right, R.anim.push_right);
                }
            });
    mAlert.setCanceledOnTouchOutside(false);
    getTitle();

    // Getting the id of the navigation fragment from the attached xml
    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_drawer);

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));

    Intent gattServiceIntent = new Intent(getApplicationContext(), BluetoothLeService.class);
    startService(gattServiceIntent);

    /**
     * Attaching the profileScanning fragment to start scanning for nearby
     * devices
     */
    ProfileScanningFragment profileScanningFragment = new ProfileScanningFragment();
    displayView(profileScanningFragment, Constants.PROFILE_SCANNING_FRAGMENT_TAG);

}

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

@Override
public void updateOrientation(Boolean newValue) {
    if (newValue) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {// w w  w  . ja  va 2  s .c  o  m
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}

From source file:com.csipsimple.ui.incall.CallActivity.java

@SuppressWarnings("deprecation")
@Override//ww w  .ja  va  2 s . c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //handler.setActivityInstance(this);
    Log.i(TAG, "######## onCreate");
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    this.setFinishOnTouchOutside(false);
    setContentView(R.layout.call_dialog);

    targetName = getIntent().getStringExtra(SipManager.CALLEE_NAME_INTENT_KEY);
    if (targetName != null) {
        Log.i(TAG, "targetName: " + targetName);
    }

    SipCallSession initialSession = getIntent().getParcelableExtra(SipManager.EXTRA_CALL_INFO);
    synchronized (callMutex) {
        callsInfo = new SipCallSession[1];
        callsInfo[0] = initialSession;
    }

    bindService(new Intent(this, SipService.class), connection, Context.BIND_AUTO_CREATE);
    prefsWrapper = new PreferencesProviderWrapper(this);

    // Log.d(TAG, "Creating call handler for " +
    // callInfo.getCallId()+" state "+callInfo.getRemoteContact());
    powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK
            | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,
            "com.csipsimple.onIncomingCall");
    wakeLock.setReferenceCounted(false);

    takeKeyEvents(true);

    // Cache findViews
    mainFrame = (ViewGroup) findViewById(R.id.mainFrame);
    //inCallControls = (InCallControls) findViewById(R.id.inCallControls);
    inCallAnswerControls = (InCallAnswerControls) findViewById(R.id.inCallAnswerControls);
    activeCallsGrid = (InCallInfoGrid) findViewById(R.id.activeCallsGrid);
    heldCallsGrid = (InCallInfoGrid) findViewById(R.id.heldCallsGrid);

    // Bind
    attachVideoPreview();

    //inCallControls.setOnTriggerListener(this);
    inCallAnswerControls.setOnTriggerListener(this);

    if (activeCallsAdapter == null) {
        activeCallsAdapter = new CallsAdapter(true);
    }
    activeCallsGrid.setAdapter(activeCallsAdapter);

    if (heldCallsAdapter == null) {
        heldCallsAdapter = new CallsAdapter(false);
    }
    heldCallsGrid.setAdapter(heldCallsAdapter);

    ScreenLocker lockOverlay = (ScreenLocker) findViewById(R.id.lockerOverlay);
    lockOverlay.setActivity(this);
    lockOverlay.setOnLeftRightListener(this);

    /*
    middleAddCall = (Button) findViewById(R.id.add_call_button);
    middleAddCall.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View arg0) {
        onTrigger(ADD_CALL, null);
    }
    });
    if (!prefsWrapper.getPreferenceBooleanValue(SipConfigManager.SUPPORT_MULTIPLE_CALLS)) {
    middleAddCall.setEnabled(false);
    middleAddCall.setText(R.string.not_configured_multiple_calls);
    }
    */

    // Listen to media & sip events to update the UI
    registerReceiver(callStateReceiver, new IntentFilter(SipManager.ACTION_SIP_CALL_CHANGED));
    registerReceiver(callStateReceiver, new IntentFilter(SipManager.ACTION_SIP_MEDIA_CHANGED));
    registerReceiver(callStateReceiver, new IntentFilter(SipManager.ACTION_ZRTP_SHOW_SAS));

    proximityManager = new CallProximityManager(this, this, lockOverlay);
    keyguardManager = KeyguardWrapper.getKeyguardManager(this);

    dialFeedback = new DialingFeedback(this, true);

    if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.PREVENT_SCREEN_ROTATION)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    if (quitTimer == null) {
        quitTimer = new Timer("Quit-timer");
    }

    useAutoDetectSpeaker = prefsWrapper.getPreferenceBooleanValue(SipConfigManager.AUTO_DETECT_SPEAKER);

    applyTheme();
    proximityManager.startTracking();

    //inCallControls.setCallState(initialSession);
    inCallAnswerControls.setCallState(initialSession);
}

From source file:com.yunluo.android.arcadehub.GameListActivity.java

private void initRightView() {
    FrameLayout.LayoutParams rightLp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT);
    mRightView = new RightView(this, mRomList);
    mRightView.setBackgroundColor(Color.WHITE);
    mFrameLayout.addView(mRightView, rightLp);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

From source file:com.f8full.casserolesencours.CasserolesEnCoursActivity.java

/** Called when the activity is first created. */
@Override//from  ww  w.j a va 2 s  .  co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Logger.getLogger("com.google.api.client").setLevel(LOGGING_LEVEL);

    //That ease dev of technical stuff BUT is not wanted on a mid/longer term
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    mTimeFilterSpinner = (Spinner) findViewById(R.id.timeFilterSpinner);
    mTimeFilterAdapter = ArrayAdapter.createFromResource(this, R.array.timeFilter_choices,
            android.R.layout.simple_spinner_item);
    mTimeFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mTimeFilterSpinner.setAdapter(mTimeFilterAdapter);

    mDistanceFilterSpinner = (Spinner) findViewById(R.id.distanceFilterSpinner);
    mDistanceFilterAdapter = ArrayAdapter.createFromResource(this, R.array.distanceFilter_choices,
            android.R.layout.simple_spinner_item);
    mDistanceFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mDistanceFilterSpinner.setAdapter(mDistanceFilterAdapter);

    mAloharAuthLayout = findViewById(R.id.auth_layout);
    mMainLayout = findViewById(R.id.main_layout);
    mProgress = findViewById(R.id.progress_spin);

    mAccountView = (TextView) findViewById(R.id.account);

    mMainHandler = new Handler();

    mStatusView = (TextView) findViewById(R.id.service_status);
    mServiceToggleButton = (ToggleButton) findViewById(R.id.toggle);
    mUIDView = (EditText) findViewById(R.id.uid);

    mNotificationManager = (NotificationManager) getSystemService(NOTIFIACTION_SERVICE_STRING);

    mAlohar = Alohar.init(getApplication());

    mPlaceManager = mAlohar.getPlaceManager();
    mMotionManager = mAlohar.getMotionManager();

    //mEventManager = EventsManager.getInstance();
    //register listener
    //mPlaceManager.registerPlaceEventListener(mEventManager);
    mMotionManager.registerMotionListener(this);

    //Alohar original, I'm testing the other one
    //mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mPrefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);

    mAloharUid = mPrefs.getString(PREF_KEY, null);
    if (mAloharUid == null) {
        mAlohar.register(APP_ID, API_KEY, this);
    }

    mFusionTableEncID = mPrefs.getString(PREF_TABLE_ENCID, null);

    mRegisterRequestTableID = mPrefs.getString(PREF_REGREQUESTTABLE_ENCID, null);

    if (mRegisterRequestTableID == null) {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(false);
    } else {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(true);
        ((Button) findViewById(R.id.registerTable)).setEnabled(false);
    }

    mViewOnMasterID = mPrefs.getString(PREF_VIEWONMASTERTABLE_ENCID, null);

    if (mViewOnMasterID == null) {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(true);
    } else {
        ((Button) findViewById(R.id.refreshRegistration)).setEnabled(false);
    }

    if (mAlohar.isServiceRunning()) {
        //findViewById(R.id.timeFilterSpinner).setClickable(true);
        mDistanceFilterSpinner.setEnabled(true);
    } else {
        //findViewById(R.id.timeFilterSpinner).setClickable(false);
        mDistanceFilterSpinner.setEnabled(false);
    }

    String tableStatus = mPrefs.getString(PREF_TABLE_STATUS, null);
    if (tableStatus == null) {
        tableStatus = getString(R.string.geolocationStatusRegRequired);
        //Setup interface
        //Done in XML file
    } else {
        //setup interface
        if (tableStatus.equals(getString(R.string.geolocationAnonymizePending))) {
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setTextColor(getResources().getColor(R.color.text_orange));
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setText(getString(R.string.geolocationAnonymizePending));

            ((Button) findViewById(R.id.registerAnonymize)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.checkAnonymize)).setVisibility(View.VISIBLE);
        } else if (tableStatus.equals(getString(R.string.geolocationAnonymizeProcessed))) {
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setTextColor(getResources().getColor(R.color.text_green));
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setText(getString(R.string.geolocationAnonymizeProcessed));

            ((Button) findViewById(R.id.checkAnonymize)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.registerAnonymize)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.logWithGoogle)).setVisibility(View.GONE);
            ((Button) findViewById(R.id.toggleGeolocation)).setVisibility(View.VISIBLE);
            findViewById(R.id.geolocationServiceStatus).setVisibility(View.VISIBLE);
            findViewById(R.id.myDataCheckbox).setEnabled(true);
        } else if (tableStatus.equals(getString(R.string.geolocationStatusRegStart))) {
            findViewById(R.id.logWithGoogle).setVisibility(View.GONE);
            findViewById(R.id.registerAnonymize).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setTextColor(getResources().getColor(R.color.text_orange));
            ((TextView) findViewById(R.id.geolocationStatus))
                    .setText(getString(R.string.geolocationStatusRegStart));
        }
    }

    ((TextView) findViewById(R.id.tableStatus)).setText(tableStatus);

    if (mAloharUid != null) {
        mUIDView.setText(String.valueOf(mAloharUid));
        onAuthenClick(mUIDView);
    } else {
        mAloharAuthLayout.setVisibility(View.VISIBLE);
    }

    mGOOGCredential = new GoogleCredential.Builder().setTransport(mNetHttpTransport)
            .setJsonFactory(mJaksonJSONFactory)//.build();
            .setClientSecrets(OAuth2ClientCredentials.CLIENT_ID, OAuth2ClientCredentials.CLIENT_SECRET).build();

    mGOOGCredential.setAccessToken(null);
    mGOOGCredential.setRefreshToken(mPrefs.getString(PREF_REFRESH_TOKEN, null));

    //Logger.getLogger("com.google.api.client").setLevel(LOGGING_LEVEL);

    Builder truc = GoogleClient.builder(mNetHttpTransport, mJaksonJSONFactory, new GenericUrl(SERVICE_URL));
    truc.setHttpRequestInitializer(mGOOGCredential);

    mGOOGClient = truc.build();

    mPollFrequencyText = (TextView) findViewById(R.id.pollFrequencyText);
    mPollFrequencyText.setText("N/A when stationary");
    //Something is wrong with the color, I'll see that cosmetic side later
    //mPollFrequencyText.setTextColor(R.color.text_violet);

    mLocationPollThreadExecutor.setKeepAliveTime(0, TimeUnit.SECONDS);

    RadioGroup pollFrequencyRadioGroup = (RadioGroup) findViewById(R.id.pollFrequencyRadioGroup);

    pollFrequencyRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            cancelActiveTasks();
            startTaskForId(checkedId, true);
        }
    });

    findViewById(R.id.frequency0).setEnabled(false);
    findViewById(R.id.frequency1).setEnabled(false);
    findViewById(R.id.frequency2).setEnabled(false);
    findViewById(R.id.frequency3).setEnabled(false);

}