List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE
int SCREEN_ORIENTATION_LANDSCAPE
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.
Click Source Link
landscape
in the android.R.attr#screenOrientation attribute. From source file:nf.frex.android.FrexActivity.java
/** * Called when the activity is first created. *//*from w w w. jav a 2s .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); } } } }
From source file:com.m2dl.mini_projet.mini_projet_android.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (screenIsLarge()) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else {// w ww .j av a 2s.c o m setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } myPhotoMarkers = new HashMap<>(); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; } locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 5, this); if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { buildAlertMessageNoGps(); } else { isGPSOn = true; } coordLat = 0.0; coordLong = 0.0; FloatingActionButton fabPhoto = (FloatingActionButton) findViewById(R.id.fabPhoto); fabPhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { takePhoto(view); } }); FloatingActionButton fabTagSelect = (FloatingActionButton) findViewById(R.id.fabTagSelect); fabTagSelect.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { selectTags(); } }); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); pointInteretManager = new PointInteretManager(this); // Init tag list allTags = new TreeSet<>(); selectedTags = new TreeSet<>(); }
From source file:io.github.msc42.masterthemaze.SearchDeviceActivity.java
private void lockScreenOrientation() { int orientation = getResources().getConfiguration().orientation; int rotation = getWindowManager().getDefaultDisplay().getRotation(); if (orientation == Configuration.ORIENTATION_LANDSCAPE) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else {//from w w w .j a va2 s . co m setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } } else if (orientation == Configuration.ORIENTATION_PORTRAIT) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }
From source file:org.kontalk.util.SystemUtils.java
/** * Returns the correct screen orientation based on the supposedly preferred * position of the device./* ww w . j av a2 s .com*/ * http://stackoverflow.com/a/16585072/1045199 */ public static int getScreenOrientation(Activity activity) { WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); Configuration configuration = activity.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); // Search for the natural position of the device if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) || configuration.orientation == Configuration.ORIENTATION_PORTRAIT && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) { // Natural position is Landscape switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; case Surface.ROTATION_180: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } } else { // Natural position is Portrait switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; case Surface.ROTATION_180: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; case Surface.ROTATION_270: return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } } return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; }
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); }// w ww.ja va 2 s . co m }
From source file:com.oo58.game.texaspoker.AppActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // this.getWindow().setFlags(FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mContext = AppActivity.this; try {//from w w w .j a v a 2 s. c o m ApplicationInfo appInfo = this.getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); String msg = appInfo.metaData.getString("data_Name"); // int channelid = Integer.parseInt(msg) ; // // System.out.println(channelid); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } mAct = this; allContext = this.getApplicationContext(); mTencent = Tencent.createInstance("1104823392", getApplicationContext()); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "MyLock"); mWakeLock.acquire(); MobclickAgent.setDebugMode(false); MobclickAgent.updateOnlineConfig(this); AnalyticsConfig.enableEncrypt(true); checkUpdate(); PackageManager pm2 = getPackageManager(); homeInfo = pm2.resolveActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 0); mNetChecker.initAndRegListener(mContext); mWXPay.init(this); MobClickCppHelper.init(this); // // logcatdebug // XGPushConfig.enableDebug(this, true); // // registerPush(getApplicationContext(), XGIOperateCallback)callback // // registerPush(getApplicationContext(),account) // // // // ApplicationContext // Context context = getApplicationContext(); // XGPushManager.registerPush(context); // // // 2.362 // Intent service = new Intent(context, XGPushService.class); // context.startService(service); // API // registerPush(context,account)registerPush(context,account, XGIOperateCallback)accountAPPqqopenid // registerPush(context,"*")account="*" // unregisterPush(context) // setTag(context, tagName) // deleteTag(context, tagName) updateListViewReceiver = new MsgReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.oo58.game.texaspoker.activity.UPDATE_LISTVIEW"); registerReceiver(updateListViewReceiver, intentFilter); XGPushManager.registerPush(getApplicationContext(), new XGIOperateCallback() { @Override public void onSuccess(Object data, int flag) { // Log.w(Constants.LogTag, // "+++ register push sucess. token:" + data); } @Override public void onFail(Object data, int errCode, String msg) { // Log.w(Constants.LogTag, // "+++ register push fail. token:" + data // + ", errCode:" + errCode + ",msg:" // + msg); } }); //javajosnC++demo /* JSONObject jsonObj = new JSONObject(); try { jsonObj.put("Int_att",25); jsonObj.put("String_att","str");//string jsonObj.put("Double_att",12.25);//double jsonObj.put("Boolean_att",true);//boolean } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }//int PushJson(jsonObj.toString()) ;*/ }
From source file:divya.myvision.TessActivity.java
/** * Initializes the UI and creates the detector pipeline. *///from w w w. j ava 2s .c o m @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.ocr_capture); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay<TessGraphic>) findViewById(R.id.graphicOverlay); // read parameters from the intent used to launch the activity. boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false); boolean useFlash = getIntent().getBooleanExtra(UseFlash, false); String fps = getIntent().getStringExtra(FPS); String fontSize = getIntent().getStringExtra(FontSize); String orientation = getIntent().getStringExtra(Orientation); String lang = getIntent().getStringExtra(Lang); if (orientation.equals("Landscape")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals("Portrait")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } Settings.setFontSize(Float.parseFloat(fontSize)); // Check for the camera permission before accessing the camera. If the // permission is not granted yet, request permission. int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (rc == PackageManager.PERMISSION_GRANTED) { createCameraSource(autoFocus, useFlash, fps); } else { requestCameraPermission(); } gestureDetector = new GestureDetector(this, new CaptureGestureListener()); scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener()); Snackbar.make(mGraphicOverlay, R.string.info_msg, Snackbar.LENGTH_LONG).show(); setLang(lang); }
From source file:org.easyrpg.player.player.EasyRpgPlayerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EasyRpgPlayerActivity.instance = this; SettingsManager.init(getApplicationContext()); // Menu configuration this.drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); drawer.setDrawerListener(new DrawerListener() { @Override//from w w w . j a va2 s .c o m public void onDrawerSlide(View view, float arg1) { drawer.bringChildToFront(view); drawer.requestLayout(); } @Override public void onDrawerStateChanged(int arg0) { } @Override public void onDrawerOpened(View arg0) { } @Override public void onDrawerClosed(View arg0) { } }); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); hideStatusBar(); // Screen orientation if (SettingsManager.isForcedLandscape()) { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } // Hardware acceleration try { if (Build.VERSION.SDK_INT >= 11) { // Api 11: FLAG_HARDWARE_ACCELERATED getWindow().setFlags(0x01000000, 0x01000000); } } catch (Exception e) { e.printStackTrace(); } // Put the gamescreen surface = mSurface; mLayout = (RelativeLayout) findViewById(R.id.main_layout); mLayout.addView(surface); updateScreenPosition(); // Project preferences buttonMappingManager = ButtonMappingManager.getInstance(this); GameInformation project = new GameInformation(getProjectPath()); project.getProjectInputLayout(buttonMappingManager); // Choose the proper InputLayout inputLayout = buttonMappingManager.getLayoutById(project.getId_input_layout()); // Add buttons addButtons(); // Set speed multiplier setFastForwardMultiplier(SettingsManager.getFastForwardMultiplier()); }
From source file:eu.thecoder4.gpl.pleftdroid.EventDetailActivity.java
/** Called when the activity is first created. */ @Override//from w w w.j a v a 2s . com public void onCreate(Bundle savedInstanceState) { if (AppPreferences.INSTANCE.getUsePleftTheme()) { setTheme(R.style.Theme_Pleft); } super.onCreate(savedInstanceState); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); initOK = true; Bundle extras = getIntent().getExtras(); aid = extras.getInt(AID); theurl = extras.getString(THEURL); if (extras.getString(FROMHL) != null) { back2main = true; } setContentView(R.layout.event_detail); // Initialize Adapters and ListViews lvd = (ListView) findViewById(R.id.pdateslv); adates = new ArrayList<ADate>(); adateadapter = new ADateAdapter(this, R.layout.detail_invitee_rowc, adates); voteadateadapter = new VoteADateAdapter(this, R.layout.detail_voting_rowdbc, adates); lvd.setAdapter(voteadateadapter); lvp = (ListView) findViewById(R.id.peoplelv); apeople = new ArrayList<APerson>(); apeopleadapter = new APersonAdapter(this, R.layout.detail_ppl_row, apeople); lvp.setAdapter(apeopleadapter); lvp.setOnItemClickListener(this); lvp.setSelection(curppos); lvp.setChoiceMode(ListView.CHOICE_MODE_SINGLE); initEvent = new Runnable() { @Override public void run() { initializeEventDetail(theurl); } }; Thread thread = new Thread(null, initEvent, "Initializer"); thread.start(); mProgressDialog = ProgressDialog.show(this, this.getString(R.string.dialog_title_pleasewaitdetails), this.getString(R.string.dialog_msg_pleasewaitdetails), true); //Toast.makeText(this, ev.toString(), Toast.LENGTH_LONG).show(); }
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 www .j a va 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; } }