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.realtek.simpleconfig.SCTest.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ??//www . ja v a 2 s.com // Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); /* just for test!!! Button button = null; button.setVisibility(View.VISIBLE); */ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); /** For Multiple Page */ setContentView(R.layout.sc_view_pager); SCViewPager = (ViewPager) findViewById(R.id.viewPagerLayout); SCInflater = LayoutInflater.from(this); sc_config_iface = SCInflater.inflate(R.layout.sc_config_iface, null); sc_control_iface = SCInflater.inflate(R.layout.sc_control_iface, null); listViews = new ArrayList<View>(); listViews.add(sc_config_iface); listViews.add(sc_control_iface); SCViewPager.setCurrentItem(0); SCViewPager.setAdapter(new PageAdpt()); SCViewPager.setOnPageChangeListener(PageChangeEvent); /** For Config Page */ scan_wifi = (Button) sc_config_iface.findViewById(R.id.scan_wifi); start_config = (Button) sc_config_iface.findViewById(R.id.start_config); scan_wifi.setTextSize(20); start_config.setTextSize(20); /* Config Button */ scan_wifi.setOnClickListener(new ButtonListener()); start_config.setOnClickListener(new ButtonListener()); /* Config ListView ? */ wifiListView = (ListView) sc_config_iface.findViewById(R.id.all_wifi_network); wifiListView.setOnItemClickListener(wifiItemOnClick); /* Config ListView ? */ wifiListItemAdapter = new listBaseAdapter(this, wifiArrayList); /* ?? */ cfgProgressDialog = new ProgressDialog(this); /** For Control Page */ discov_devs = (Button) sc_control_iface.findViewById(R.id.discov_devs); discov_devs.setTextSize(20); /* Control Button */ discov_devs.setOnClickListener(new ButtonListener()); /* Control ListView ? */ devListView = (ListView) sc_control_iface.findViewById(R.id.all_connected_devs); devListView.setOnItemClickListener(devItemOnClick); /* Control ListView ? */ devListItemAdapter = new listBaseAdapter(this, devArrayList); /* ? */ discovDialog = new ProgressDialog(this); delProfDialog = new ProgressDialog(this); renameDevDialog = new ProgressDialog(this); /** Simple Config ? */ SCLib.rtk_sc_init(); SCLib.TreadMsgHandler = new MsgHandler(); /** ?? */ SCLib.WifiInit(this); wifiMngr = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiInfo = wifiMngr.getConnectionInfo(); fileOps.SetKey(SCLib.WifiGetMacStr()); fileOps.UpgradeSsidPasswdFile(); }
From source file:org.openremote.android.console.GroupActivity.java
/** * Inits a orientation listener, set request orientation be sensor when the current screen's orientation equals device orientation. *//*w w w. j a v a 2 s. co m*/ private void initOrientationListener() { OrientationEventListener orientationListener = new OrientationEventListener(this) { @Override public void onOrientationChanged(int orientation) { if (currentScreen == null) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); return; } if (orientation > 315 || orientation < 45 || (orientation > 135 && orientation < 225)) { // portrait if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && !currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (!currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else if ((orientation > 225 && orientation < 315) || (orientation > 45 && orientation < 135)) { // landscape if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } } }; orientationListener.enable(); }
From source file:com.mirasense.demos.scan_using_zbar_in_fragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);/*from ww w.j a v a2 s . com*/ View rootView = inflater.inflate(R.layout.main, container, false); MainActivity.global = 2; // Toast.makeText(getActivity(), "call codebar", 30).show(); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); autoFocusHandler = new Handler(); mCamera = getCameraInstance(); /* Instance barcode scanner */ scanner = new ImageScanner(); scanner.setConfig(0, Config.X_DENSITY, 3); scanner.setConfig(0, Config.Y_DENSITY, 3); mPreview = new CameraPreview(getActivity(), mCamera, previewCb, autoFocusCB); FrameLayout preview = (FrameLayout) rootView.findViewById(R.id.cameraPreview); preview.addView(mPreview); scanText = (TextView) rootView.findViewById(R.id.scanText); scanButton = (Button) rootView.findViewById(R.id.ScanButton); scanimage = (ImageView) rootView.findViewById(R.id.Scanbarcodeimage); scanButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (barcodeScanned) { barcodeScanned = false; scanText.setText("Scanning..."); mCamera.setPreviewCallback(previewCb); mCamera.startPreview(); previewing = true; mCamera.autoFocus(autoFocusCB); } } }); return rootView; }
From source file:com.brq.wallet.activity.ScanActivity.java
private int getScreenOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int height = dm.heightPixels; int orientation; // if the device's natural orientation is portrait: if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; default://from w ww .j a v a 2 s . c o m // Unknown screen orientation. Defaulting to portrait. orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; } } // if the device's natural orientation is landscape or if the device is square: else { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; default: // Unknown screen orientation. Defaulting to landscape. orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; } } return orientation; }
From source file:com.darly.im.ui.LauncherActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { int pid = android.os.Process.myPid(); if (mLauncherUI != null) { LogUtil.i(LogUtil.getLogUtilsTag(LauncherActivity.class), "finish last LauncherUI"); mLauncherUI.finish();//from w ww . j a va2 s .co m } // CCPAppManager.addActivityUI(mLauncherUI); mLauncherUI = this; mLauncherInstanceCount++; super.onCreate(savedInstanceState); initWelcome(); mOverflowHelper = new OverflowHelper(this); // umeng MobclickAgent.updateOnlineConfig(this); MobclickAgent.setDebugMode(true); // ?? setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ECContentObservers.getInstance().initContentObserver(); // ???? userNum = getIntent().getStringExtra("tel"); // ? if (!APP.isNetworkConnected(this)) { ToastApp.showToast(R.string.neterror); return; } else { HttpClient.post(ConsHttpUrl.FRIEND, "", new RequestCallBack<String>() { @Override public void onSuccess(ResponseInfo<String> arg0) { // TODO Auto-generated method stub LogUtils.i(arg0.result); SharePreferCache.putValue( SharePreferHelp.getValue(APPEnum.USERVOIP.getDec(), null) + SharePreferCache.CACHE, APPEnum.ECCONTACTS.getDec(), arg0.result); } @Override public void onFailure(HttpException arg0, String arg1) { // TODO Auto-generated method stub } }); } }
From source file:co.taqat.call.CallActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }/*from w ww . j av a2 s .c om*/ getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.call); isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers); if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { BluetoothManager.getInstance().initBluetooth(); } cameraNumber = AndroidCameraConfiguration.retrieveCameras().length; try { // Yeah, this is hidden field. field = PowerManager.class.getClass().getField("PROXIMITY_SCREEN_OFF_WAKE_LOCK").getInt(null); } catch (Throwable ignored) { } powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(field, getLocalClassName()); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); mListener = new LinphoneCoreListenerBase() { @Override public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { displayMissedChats(); } @Override public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) { if (LinphoneManager.getLc().getCallsNb() == 0) { finish(); return; } if (state == State.IncomingReceived) { startIncomingCallActivity(); return; } else if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) { if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(false); } if (isVideoEnabled(call)) { showAudioView(); } } else if (state == State.Resuming) { if (LinphonePreferences.instance().isVideoEnabled()) { status.refreshStatusItems(call, isVideoEnabled(call)); if (call.getCurrentParamsCopy().getVideoEnabled()) { showVideoView(); } } if (LinphoneManager.getLc().getCurrentCall() != null) { enabledVideoButton(true); } } else if (state == State.StreamsRunning) { switchVideo(isVideoEnabled(call)); enableAndRefreshInCallActions(); if (status != null) { videoProgress.setVisibility(View.GONE); status.refreshStatusItems(call, isVideoEnabled(call)); } } else if (state == State.CallUpdatedByRemote) { // If the correspondent proposes video while audio call boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled(); if (!videoEnabled) { acceptCallUpdate(false); } boolean remoteVideo = call.getRemoteParams().getVideoEnabled(); boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled(); boolean autoAcceptCameraPolicy = true;//LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests(); if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) { showAcceptCallUpdateDialog(); timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) { public void onTick(long millisUntilFinished) { } public void onFinish() { //TODO dismiss dialog acceptCallUpdate(false); } }.start(); /*showAcceptCallUpdateDialog(); timer = new CountDownTimer(SECONDS_BEFORE_DENYING_CALL_UPDATE, 1000) { public void onTick(long millisUntilFinished) { } public void onFinish() { //TODO dismiss dialog } }.start();*/ } // else if (remoteVideo && !LinphoneManager.getLc().isInConference() && autoAcceptCameraPolicy) { // mHandler.post(new Runnable() { // @Override // public void run() { // acceptCallUpdate(true); // } // }); // } } refreshIncallUi(); transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null); } @Override public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) { if (status != null) { if (call.getCurrentParamsCopy().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()) { status.showZRTPDialog(call); } status.refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled()); } } }; if (findViewById(R.id.fragmentContainer) != null) { initUI(); if (LinphoneManager.getLc().getCallsNb() > 0) { LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; if (LinphoneUtils.isCallEstablished(call)) { enableAndRefreshInCallActions(); } } if (savedInstanceState != null) { // Fragment already created, no need to create it again (else it will generate a memory leak with duplicated fragments) isSpeakerEnabled = savedInstanceState.getBoolean("Speaker"); isMicMuted = savedInstanceState.getBoolean("Mic"); isVideoCallPaused = savedInstanceState.getBoolean("VideoCallPaused"); refreshInCallActions(); return; } else { isSpeakerEnabled = LinphoneManager.getLc().isSpeakerEnabled(); isMicMuted = LinphoneManager.getLc().isMicMuted(); } Fragment callFragment; if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) { callFragment = new CallVideoFragment(); videoCallFragment = (CallVideoFragment) callFragment; displayVideoCall(false); LinphoneManager.getInstance().routeAudioToSpeaker(); isSpeakerEnabled = true; } else { callFragment = new CallAudioFragment(); audioCallFragment = (CallAudioFragment) callFragment; } if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { BluetoothManager.getInstance().routeAudioToBluetooth(); } callFragment.setArguments(getIntent().getExtras()); getFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment) .commitAllowingStateLoss(); } }
From source file:com.google.android.gms.cast.samples.tictactoe.GameActivity.java
/** * Returns the screen configuration to portrait mode whenever changed. *//*from ww w. j a va2 s .c o m*/ @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
From source file:com.hichinaschool.flashcards.anki.StudyOptionsActivity.java
/** Handles item selections */ @Override/* w ww . j a v a 2 s . co m*/ public boolean onOptionsItemSelected(MenuItem item) { Resources res = this.getResources(); switch (item.getItemId()) { case android.R.id.home: closeStudyOptions(); return true; case MENU_PREFERENCES: startActivityForResult(new Intent(this, Preferences.class), StudyOptionsFragment.PREFERENCES_UPDATE); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.FADE); } return true; case MENU_ROTATE: if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } return true; case MENU_NIGHT: SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this); if (preferences.getBoolean("invertedColors", false)) { preferences.edit().putBoolean("invertedColors", false).commit(); item.setIcon(R.drawable.ic_menu_night); } else { preferences.edit().putBoolean("invertedColors", true).commit(); item.setIcon(R.drawable.ic_menu_night_checked); } return true; case DeckPicker.MENU_CREATE_DYNAMIC_DECK: StyledDialog.Builder builder = new StyledDialog.Builder(StudyOptionsActivity.this); builder.setTitle(res.getString(R.string.new_deck)); mDialogEditText = new EditText(StudyOptionsActivity.this); ArrayList<String> names = AnkiDroidApp.getCol().getDecks().allNames(); int n = 1; String cramDeckName = "Cram 1"; while (names.contains(cramDeckName)) { n++; cramDeckName = "Cram " + n; } mDialogEditText.setText(cramDeckName); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder.setView(mDialogEditText, false, false); builder.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { long id; Bundle initialConfig = new Bundle(); try { initialConfig.putString("searchSuffix", "'deck:" + AnkiDroidApp.getCol().getDecks().current().getString("name") + "'"); id = AnkiDroidApp.getCol().getDecks().newDyn(mDialogEditText.getText().toString()); AnkiDroidApp.getCol().getDecks().get(id); } catch (JSONException e) { throw new RuntimeException(e); } loadContent(false, initialConfig); } }); builder.setNegativeButton(res.getString(R.string.cancel), null); builder.create().show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.yuntongxun.ecdemo.ui.LauncherActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { int pid = android.os.Process.myPid(); if (mLauncherUI != null) { LogUtil.i(LogUtil.getLogUtilsTag(LauncherActivity.class), "finish last LauncherUI"); mLauncherUI.finish();/*from w w w . j ava 2 s .c om*/ } // CCPAppManager.addActivityUI(mLauncherUI); mLauncherUI = this; mLauncherInstanceCount++; super.onCreate(savedInstanceState); initWelcome(); mOverflowHelper = new OverflowHelper(this); // umeng MobclickAgent.updateOnlineConfig(this); MobclickAgent.setDebugMode(true); // ?? setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ECContentObservers.getInstance().initContentObserver(); }