List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT
int SCREEN_ORIENTATION_PORTRAIT
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT.
Click Source Link
portrait
in the android.R.attr#screenOrientation attribute. From source file:com.orangelabs.rcs.ri.messaging.chat.ChatView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Set layout */ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.chat_view);/* w ww. jav a 2 s. c o m*/ initialize(); HistoryUriBuilder uriBuilder = new HistoryUriBuilder(HistoryLog.CONTENT_URI); uriBuilder.appendProvider(ChatLog.Message.HISTORYLOG_MEMBER_ID); uriBuilder.appendProvider(FileTransferLog.HISTORYLOG_MEMBER_ID); mUriHistoryProvider = uriBuilder.build(); /* Set message composer callbacks */ mComposeText = (EditText) findViewById(R.id.userText); mComposeText.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (KeyEvent.ACTION_DOWN != event.getAction()) { return false; } switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: sendText(); return true; } return false; } }); mComposeText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Check if the text is not null. // we do not wish to consider putting the edit text back to null // (like when sending message), is having activity if (!TextUtils.isEmpty(s)) { // Warn the composing manager that we have some activity if (mComposingManager != null) { mComposingManager.hasActivity(); } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); /* Set send button listener */ Button sendBtn = (Button) findViewById(R.id.send_button); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendText(); } }); /* Initialize the adapter. */ mAdapter = new ChatCursorAdapter(this, isSingleChat()); // Associate the list adapter with the ListView. ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(mAdapter); registerForContextMenu(listView); if (!isServiceConnected(RcsServiceName.CHAT, RcsServiceName.CONTACT, RcsServiceName.CAPABILITY, RcsServiceName.FILE_TRANSFER)) { showMessageThenExit(R.string.label_service_not_available); return; } startMonitorServices(RcsServiceName.CHAT, RcsServiceName.CONTACT, RcsServiceName.CAPABILITY, RcsServiceName.FILE_TRANSFER); mChatService = getChatApi(); mFileTransferService = getFileTransferApi(); processIntent(getIntent()); }
From source file:com.example.appf.CS3570.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();//from www . j a va2s .c om Bundle extras = intent.getExtras(); cam = false; // Just in case we are coming from the ServerActivity if (extras != null) { if (extras.containsKey("server_name")) SERVER_IP = extras.getString("server_name"); if (extras.containsKey("server_port")) SERVERPORT = Integer.parseInt(extras.getString("server_port")); } filter = new IMUfilter(.1f, 5); filter.reset(); // Set up reset button Button b = new Button(this); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { filter.reset(); } }); b.setText("Reset"); // Set up camera mode. Are we going to use this? Button c = new Button(this); c.setText("Camera Mode"); c.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { filter.reset(); mGLView.mRenderer.mCamera = new Camera(); cam = !cam; } }); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); ll.setBackgroundColor(Color.parseColor("#21C9FF")); ll.addView(b); ll.addView(c); // Create a GLSurfaceView instance and set it // as the ContentView for this Activity mGLView = new MyGLSurfaceView(this, this); ll.addView(mGLView); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); gyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); magnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); setContentView(ll); new Thread(new SocketThread()).start(); }
From source file:com.villasoftgps.movil.Act_Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // se instancia las preferencias de la aplicacion if (villaprefs == null) { villaprefs = getApplicationContext().getSharedPreferences(PREFS_NAME, MODE_PRIVATE); }/*from www. ja va2 s . c o m*/ // se instancia el editor de preferencias prefsedit = villaprefs.edit(); /* * se valida que exista un usuario en las preferencia * de lo contrario se cierra la sesin y se redirecciona al login */ String strClient = villaprefs.getString(PROPERTY_USER, ""); if (strClient.equals("")) { Intent frm = new Intent(Act_Main.this, Act_Login.class); startActivity(frm); finish(); } gson = new Gson(); /* se instancia la clase cliente con los datos del usuario almacenado en las preferencias */ client = new Client(); client = gson.fromJson(strClient, Client.class); /* se instancia la clase que contiene los atributos u opciones de las preferencias */ preferences = new Preferences(); String strPreferences = villaprefs.getString(PROPERTY_PREFS, ""); if (!strPreferences.equals("")) { preferences = gson.fromJson(villaprefs.getString(PROPERTY_PREFS, ""), Preferences.class); } /* se valida si la aplicacion se encuentra en status de bloqueo, de ser asi, se redirecciona a la actividad de bloqueado. */ if (preferences.isLocked()) { Intent frm_Locked = new Intent(Act_Main.this, Act_Locked.class); startActivity(frm_Locked); } setContentView(R.layout.activity_main); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); /* se instancia el objeto del mapa */ SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); /* se instancia el listview que contendr la lista de dispositivos y vehiculos del cliente logueado. */ lvDevices = (ListView) findViewById(R.id.lvDevices); View lvDevicesHeader = getLayoutInflater().inflate(R.layout.lv_menu_header, null); VillaTextView lblEmail = (VillaTextView) lvDevicesHeader.findViewById(R.id.lblEmail); VillaTextView lblUser = (VillaTextView) lvDevicesHeader.findViewById(R.id.lblUser); VillaImageView imgProfile = (VillaImageView) lvDevicesHeader.findViewById(R.id.imgProfile); String userName = client.getFirstName() + " " + client.getLastName(); lblUser.setText(userName); String userEmail = "(" + client.getEmail() + ")"; lblEmail.setText(userEmail); if (client.getImage().equals("")) { Glide.with(Act_Main.this).load(R.drawable.icon_profile).centerCrop().crossFade().into(imgProfile); } else { byte[] image = Base64.decode(client.getImage(), 0); Glide.with(Act_Main.this).load(image).centerCrop().crossFade().into(imgProfile); } /* se cargan los items del lvDevices y el adapter */ lvDevices.addHeaderView(lvDevicesHeader); devicesAdapter = new DevicesAdapter(Act_Main.this, client.getDevices()); lvDevices.setAdapter(devicesAdapter); /* se ejecuta el procedimiento asincrono para cargar la lista de dispositivos correspondientes al cliente logueado */ new AsyncGetDevices().execute(client.getClientId()); /* se instancian el resto de controles que contiene la actividad */ drawerLayout = (DrawerLayout) findViewById(R.id.drawer_menu); btnMenu = (Button) findViewById(R.id.btnMenu); btnMapaRoad = (Button) findViewById(R.id.btnMapaRoad); btnMapaSatelite = (Button) findViewById(R.id.btnMapaSatelite); btnLock = (Button) findViewById(R.id.btnLock); btnLogout = (Button) findViewById(R.id.btnLogout); btnMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mostrarOcultarMenu(); } }); btnMapaRoad.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mapa.setMapType(GoogleMap.MAP_TYPE_NORMAL); } }); btnMapaSatelite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mapa.setMapType(GoogleMap.MAP_TYPE_SATELLITE); } }); btnLock.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent frmLocked = new Intent(Act_Main.this, Act_Locked.class); startActivity(frmLocked); } }); btnLogout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mostrarMensaje(false, DialogType.PROMPT, R.drawable.icon_prompt, getString(R.string.prompt_cerrar_sesion), Ejecutar.LOGOUT); } }); }
From source file:net.olejon.spotcommander.WebViewActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Google API client mGoogleApiClient = new GoogleApiClient.Builder(mContext).addApiIfAvailable(Wearable.API).build(); // Allow landscape? if (!mTools.allowLandscape()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Hide status bar? if (mTools.getDefaultSharedPreferencesBoolean("HIDE_STATUS_BAR")) getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Power manager final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "wakeLock"); // Settings//from ww w . j av a 2s. c o m mTools.setSharedPreferencesBoolean("CAN_CLOSE_COVER", false); // Current network mCurrentNetwork = mTools.getCurrentNetwork(); // Computer final long computerId = mTools.getSharedPreferencesLong("LAST_COMPUTER_ID"); final String[] computer = mTools.getComputer(computerId); final String uri = computer[0]; final String username = computer[1]; final String password = computer[2]; // Layout setContentView(R.layout.activity_webview); // Status bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mStatusBarPrimaryColor = getWindow().getStatusBarColor(); mStatusBarCoverArtColor = mStatusBarPrimaryColor; } // Notification mPersistentNotificationIsSupported = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); if (mPersistentNotificationIsSupported) { final Intent launchActivityIntent = new Intent(mContext, MainActivity.class); launchActivityIntent.setAction("android.intent.action.MAIN"); launchActivityIntent.addCategory("android.intent.category.LAUNCHER"); mLaunchActivityPendingIntent = PendingIntent.getActivity(mContext, 0, launchActivityIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent hideIntent = new Intent(mContext, RemoteControlIntentService.class); hideIntent.setAction("hide_notification"); hideIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mHidePendingIntent = PendingIntent.getService(mContext, 0, hideIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent previousIntent = new Intent(mContext, RemoteControlIntentService.class); previousIntent.setAction("previous"); previousIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mPreviousPendingIntent = PendingIntent.getService(mContext, 0, previousIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent playPauseIntent = new Intent(mContext, RemoteControlIntentService.class); playPauseIntent.setAction("play_pause"); playPauseIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mPlayPausePendingIntent = PendingIntent.getService(mContext, 0, playPauseIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent nextIntent = new Intent(mContext, RemoteControlIntentService.class); nextIntent.setAction("next"); nextIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mNextPendingIntent = PendingIntent.getService(mContext, 0, nextIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent volumeDownIntent = new Intent(mContext, RemoteControlIntentService.class); volumeDownIntent.setAction("adjust_spotify_volume_down"); volumeDownIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mVolumeDownPendingIntent = PendingIntent.getService(mContext, 0, volumeDownIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent volumeUpIntent = new Intent(mContext, RemoteControlIntentService.class); volumeUpIntent.setAction("adjust_spotify_volume_up"); volumeUpIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mVolumeUpPendingIntent = PendingIntent.getService(mContext, 0, volumeUpIntent, PendingIntent.FLAG_CANCEL_CURRENT); mNotificationManager = NotificationManagerCompat.from(mContext); mNotificationBuilder = new NotificationCompat.Builder(mContext); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) mNotificationBuilder.setPriority(Notification.PRIORITY_MAX); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mNotificationBuilder.setVisibility(Notification.VISIBILITY_PUBLIC); mNotificationBuilder.setCategory(Notification.CATEGORY_TRANSPORT); } } // Web view mWebView = (WebView) findViewById(R.id.webview_webview); mWebView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.background)); mWebView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY); mWebView.setWebViewClient(new WebViewClient() { @SuppressWarnings("deprecation") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url != null && !url.contains(uri) && !url.contains("olejon.net/code/spotcommander/api/1/spotify/") && !url.contains("accounts.spotify.com/") && !url.contains("facebook.com/")) { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } return false; } @Override public void onReceivedHttpAuthRequest(WebView view, @NonNull HttpAuthHandler handler, String host, String realm) { if (handler.useHttpAuthUsernamePassword()) { handler.proceed(username, password); } else { handler.cancel(); mWebView.stopLoading(); mTools.showToast(getString(R.string.webview_authentication_failed), 1); mTools.navigateUp(mActivity); } } @Override public void onReceivedError(WebView view, WebResourceRequest webResourceRequest, WebResourceError webResourceError) { mWebView.stopLoading(); mTools.showToast(getString(R.string.webview_error), 1); mTools.navigateUp(mActivity); } @Override public void onReceivedSslError(WebView view, @NonNull SslErrorHandler handler, SslError error) { handler.cancel(); mWebView.stopLoading(); new MaterialDialog.Builder(mContext).title(R.string.webview_dialog_ssl_error_title) .content(getString(R.string.webview_dialog_ssl_error_message)) .positiveText(R.string.webview_dialog_ssl_error_positive_button) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { finish(); } }).contentColorRes(R.color.black).show(); } }); // User agent mProjectVersionName = mTools.getProjectVersionName(); final String uaAppend1 = (!username.equals("") && !password.equals("")) ? "AUTHENTICATION_ENABLED " : ""; final String uaAppend2 = (mTools.getSharedPreferencesBoolean("WEAR_CONNECTED")) ? "WEAR_CONNECTED " : ""; final String uaAppend3 = (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT && !mTools.getDefaultSharedPreferencesBoolean("HARDWARE_ACCELERATED_ANIMATIONS")) ? "DISABLE_CSSTRANSITIONS DISABLE_CSSTRANSFORMS3D " : ""; // Web settings final WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(false); webSettings.setUserAgentString(getString(R.string.webview_user_agent, webSettings.getUserAgentString(), mProjectVersionName, uaAppend1, uaAppend2, uaAppend3)); // Load app if (savedInstanceState != null) { mWebView.restoreState(savedInstanceState); } else { mWebView.loadUrl(uri); } // JavaScript interface mWebView.addJavascriptInterface(new JavaScriptInterface(), "Android"); }
From source file:com.TomatoSauceStudio.OnTimeBirthdayPost.OnTimeBirthdayPost.java
/** Called when the activity is first created. */ @Override/* www. j ava2 s. com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * Request custom title-bar so we can display our own messages. */ requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar); titleText = (TextView) findViewById(R.id.titlet); /** * Fix our orientation, the list looks best in Portrait and this way we * don't have to deal with orientation changes. */ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); /** * We will use this progress dialog throughout to display busy messages. */ pdialog = new ProgressDialog(this); pdialog.setIndeterminate(true); /** * Init Facebook objects. */ facebook = new Facebook(APP_SECRET); mAsyncRunner = new AsyncFacebookRunner(facebook); /** * Init DB. */ mDbHelper = new BirthdaysDbAdapter(this); mDbHelper.open(); /** * Init the geocoder that will help us map locations to longitude and thus approximate timezone. */ geocoder = new Geocoder(this, Locale.getDefault()); registerForContextMenu(getListView()); /** * Get existing access_token if any and skip authorization if possible. */ mPrefs = getPreferences(MODE_PRIVATE); String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if (access_token != null) { facebook.setAccessToken(access_token); } if (expires != 0) { facebook.setAccessExpires(expires); } /** * Request FB auth again only if current session is invalid, else proceed to * request info from FB. */ if (!facebook.isSessionValid()) { //Log.d("OnTimeBirthdayPost","Facebook session not valid. Redoing auth."); fbAuthWrapper(); } else { //Log.d("OnTimeBirthdayPost","Facebook session valid. Proceeding to requests"); makeFBRequests(); } }
From source file:com.af.synapse.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { startTime = System.nanoTime(); Utils.mainActivity = this; Utils.density = getResources().getDisplayMetrics().density; Utils.imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); Synapse.openExecutor();/*from w w w. j a va2 s .c om*/ requestWindowFeature(Window.FEATURE_ACTION_BAR); Settings.setWallpaper(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { SystemBarTintManager tintManager = new SystemBarTintManager(this); if (Settings.getAppTheme() == Settings.Theme.TRANSLUCENT_DARK) { tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(R.drawable.black_gradient_270); } if (Utils.hasSoftKeys(getWindowManager())) { tintManager.setNavigationBarTintEnabled(true); tintManager.setNavigationBarTintResource(R.drawable.black_gradient_90); } } getActionBar().hide(); setPaddingDimensions(); setContentView(R.layout.activity_loading); if (!Utils.appStarted) this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onCreate(fragments == null ? null : savedInstanceState); if (fragments == null) { if (Synapse.currentEnvironmentState != Synapse.environmentState.VALID_ENVIRONMENT) { findViewById(R.id.initialProgressBar).setVisibility(View.INVISIBLE); switch (Synapse.currentEnvironmentState) { case ROOT_FAILURE: ((TextView) findViewById(R.id.initialText)).setText(R.string.initial_no_root); break; case UCI_FAILURE: ((TextView) findViewById(R.id.initialText)).setText(R.string.initial_no_uci); break; case JSON_FAILURE: ((TextView) findViewById(R.id.initialText)).setText(R.string.initial_json_parse); } return; } } mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); /** * The UI building continues in buildFragment after fragment generation, or if * the fragments are already live, continue here. */ if (fragmentsDone.get() == Utils.configSections.size()) continueCreate(); }
From source file:com.gao.im.ui.ECLauncherUI.java
@Override protected void onCreate(Bundle savedInstanceState) { if (mLauncherUI != null) { LogUtil.i(LogUtil.getLogUtilsTag(ECLauncherUI.class), "finish last LauncherUI"); mLauncherUI.finish();/*from www .j av a2 s . c o m*/ } mLauncherUI = this; mLauncherInstanceCount++; super.onCreate(savedInstanceState); initWelcome(); mOverflowHelper = new OverflowHelper(this); // umeng MobclickAgent.updateOnlineConfig(this); MobclickAgent.setDebugMode(true); // ?? setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
From source file:processing.android.PFragment.java
public void setOrientation(int which) { if (which == PORTRAIT) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (which == LANDSCAPE) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }/*from w w w . jav a 2 s . c o m*/ }
From source file:com.jwork.spycamera.SpyCamActivity.java
private void getDefaultOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); //If Naturally landscape (tablets) log.v(this, "Display pixels: " + dm.widthPixels + "x" + dm.heightPixels + "|Rotation:" + rotation); if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && dm.widthPixels > dm.heightPixels) || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && dm.widthPixels < dm.heightPixels)) { rotation += 1;//from w ww. j a v a 2 s .c om if (rotation > 3) { rotation = 0; } } switch (rotation) { case Surface.ROTATION_0: defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_90: if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; } else { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; setRequestedOrientation(defaultOrientation); } break; case Surface.ROTATION_180: if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } else { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; setRequestedOrientation(defaultOrientation); } break; case Surface.ROTATION_270: if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } else { defaultOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; setRequestedOrientation(defaultOrientation); } break; } }
From source file:nf.frex.android.FrexActivity.java
/** * Called when the activity is first created. *//*from w w w. ja v a2s. c o m*/ @Override public void onCreate(Bundle savedInstanceState) { //Log.d(TAG, "onCreate(savedInstanceState=" + savedInstanceState + ")"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY); if (PRE_SDK14) { requestWindowFeature(Window.FEATURE_NO_TITLE); // Fix: Frex to stop working on screen orientation changes (Android 2.3.x only) if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else { getActionBar().setBackgroundDrawable(new PaintDrawable(Color.argb(128, 0, 0, 0))); } view = new FractalView(this); setContentView(view); if (!tryReadingFrexDocIntent(getIntent())) { if (savedInstanceState != null) { view.restoreInstanceState(new BundlePropertySet(savedInstanceState)); } else { PropertySet propertySet = (PropertySet) getLastNonConfigurationInstance(); if (propertySet != null) { view.restoreInstanceState(propertySet); } } } }