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.cybussolutions.wikki.afri_pay.SignUp.java
@SuppressLint("NewApi") @Override// ww w.ja va2s.com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_up); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); android.support.v7.app.ActionBar ab = getSupportActionBar(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Enable the Up button if (ab != null) { ab.setHomeAsUpIndicator(R.drawable.ic_back); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle("Registration"); } // BugSenseHandler.initAndStartSession(this, "1c9ce82c"); // chromeHelpPopup = new ChromeHelpPopup(SignUp.this, "Password should contain capital and small alphabets, one number and one special character. Example: Cybus@12"); // SelectedDateView = (TextView) findViewById(R.id.DatePickerInput); // imageView=(ImageView)findViewById(R.id.signup_imageView); firstname = (EditText) findViewById(R.id.signup_firstName); lastname = (EditText) findViewById(R.id.signup_lastName); email = (EditText) findViewById(R.id.signup_email); mobile = (EditText) findViewById(R.id.signup_mobile); gender = (RadioGroup) findViewById(R.id.genderRG); gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.mrRB: { genderText = "Male"; title = "Mr"; break; } case R.id.missRB: { genderText = "Female"; title = "Miss"; break; } case R.id.mrsRB: { genderText = "Female"; title = "Mrs"; break; } default: { break; } } } }); // idNo=(EditText) findViewById(R.id.signup_idNum); /* buttonchoose=(Button) findViewById(R.id.uploadimage); buttonchoose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // openGallery(v); } });*/ try { Button b = (Button) findViewById(R.id.signup_register); if (b != null) { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub submit(v); } }); } Button cancel = (Button) findViewById(R.id.signup_cancel); if (cancel != null) { cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); } } catch (Exception e) { e.printStackTrace(); } /* doctype=(RadioGroup) findViewById(R.id.signup_doctype); doctype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.signup_passport: value = "Passport"; typeid="5"; break; case R.id.signup_license: value = "Driving License"; typeid="4"; break; } } });*/ String COmpare = "United Kingdom"; CountriesObjects = new ArrayList<>(); CountriesName = new ArrayList<>(); DataBase DataBase = new DataBase(SignUp.this); CountriesObjects = DataBase.getCountriesDB(""); for (int i = 0; i < CountriesObjects.size(); i++) { CountriesName.add(CountriesObjects.get(i).getCountry_name()); } country = (Spinner) findViewById(R.id.signup_countries_spinner); ArrayAdapter adapter201 = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, CountriesName); country.setAdapter(adapter201); if (!COmpare.equals(null)) { int spinnerPosition = adapter201.getPosition(COmpare); country.setSelection(spinnerPosition); } country.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub // InputMethodManager inputMethodManager = (InputMethodManager) // getSystemService(Activity.INPUT_METHOD_SERVICE); // inputMethodManager.hideSoftInputFromWindow(getCurrentFocus() // .getWindowToken(), 0); return false; } }); country.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) { // TODO Auto-generated method stub countrycode = (TextView) findViewById(R.id.signup_code); countrycode.setText("+" + CountriesObjects.get(pos).getCalling_code()); countrycode.setEnabled(false); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); // user_name = (EditText) findViewById(R.id.signup_userName); password = (EditText) findViewById(R.id.signup_password); re_password = (EditText) findViewById(R.id.signup_confirmpassword); re_password.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub EditText e = (EditText) findViewById(R.id.signup_password); String pass = e.getText().toString(); TextView d = (TextView) findViewById(R.id.matchPassword); if (!pass.contentEquals(s)) { d.setText("Passwords Do not Match"); d.setVisibility(View.VISIBLE); } else { d.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); }
From source file:org.linphone.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 www . j a va2 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); cameraNumber = AndroidCameraConfiguration.retrieveCameras().length; mEncoderTexts = new HashMap<String, String>(); mDecoderTexts = new HashMap<String, String>(); 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.getCurrentParams().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.getCurrentParams().getVideoEnabled(); boolean autoAcceptCameraPolicy = LinphonePreferences.instance() .shouldAutomaticallyAcceptVideoRequests(); if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) { showAcceptCallUpdateDialog(); createTimerForDialog(SECONDS_BEFORE_DENYING_CALL_UPDATE); } // 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.getCurrentParams().getMediaEncryption().equals(LinphoneCore.MediaEncryption.ZRTP) && !call.isAuthenticationTokenVerified()) { status.showZRTPDialog(call); } status.refreshStatusItems(call, call.getCurrentParams().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"); if (savedInstanceState.getBoolean("AskingVideo")) { showAcceptCallUpdateDialog(); TimeRemind = savedInstanceState.getLong("TimeRemind"); createTimerForDialog(TimeRemind); } 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.yuntongxun.schoolgroup.ui.LauncherActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { int pid = android.os.Process.myPid(); Intent intentGroup = new Intent(); intentGroup.setAction("com.yuntongxun.ecdemo.inited"); sendBroadcast(intentGroup);/*from w w w.j a v a2 s.c o m*/ if (mLauncherUI != null) { LogUtil.i(LogUtil.getLogUtilsTag(LauncherActivity.class), "finish last LauncherUI"); mLauncherUI.finish(); } // 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(); }
From source file:com.mydatingapp.ui.base.SkBaseInnerActivity.java
protected void onCreate(final Bundle savedInstanceState, int layoutResourceId) { setTheme(R.style.SkTheme);// w w w.j a v a 2 s. com super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.base_inner_activity); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); noIntConnection = (TextView) findViewById(R.id.no_int_connection); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View contentView = inflater.inflate(layoutResourceId, null, false); mDrawerLayout.addView(contentView, 0); // TODO remove dirty hack mTitle = mDrawerTitle = getTitle(); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mAdapter = new SidebarMenuAdapter(); mDrawerList.setAdapter(mAdapter); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); updateSidebarData(SkApplication.getMenuInfo()); LocalBroadcastManager.getInstance(this).registerReceiver(sidebarMenuReceiver, new IntentFilter("base.update_sidebar_menu_item_counter")); LocalBroadcastManager.getInstance(this).registerReceiver(siteInfoUpdateReceiver, new IntentFilter("base.site_info_updated")); LocalBroadcastManager.getInstance(this).registerReceiver(internetConnectionStateReceiver, new IntentFilter(SkApplication.EVENT_INTERNET_CONNECTION_STATE)); }
From source file:com.vrs.reqdroid.fragments.DependenciasFragment.java
/** * Inicializa variaveis da classe.// ww w . j a va 2 s. c o m */ void init() { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); idProjeto = ProjetoUtils.getIdProjeto(); lvDependencias = (ListView) rootView.findViewById(R.id.lvDependencias); dependencias = new ArrayList<Dependencia>(); spinnerPrimeiroRequisito = (Spinner) rootView.findViewById(R.id.spinnerRequisito1); spinnerSegundoRequisito = (Spinner) rootView.findViewById(R.id.spinnerRequisito2); }
From source file:com.tkjelectronics.balanduino.BalanduinoActivity.java
@Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; context = getApplicationContext();//www . j a v a 2s . c o m if (!getResources().getBoolean(R.bool.isTablet)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set portrait mode only - for small screens like phones else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); // Full screen rotation else setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); // Full screen rotation new Handler().postDelayed(new Runnable() { // Hack to hide keyboard when the layout it rotated @Override public void run() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Hide the keyboard - this is needed when the device is rotated imm.hideSoftInputFromWindow(getWindow().getDecorView().getApplicationWindowToken(), 0); } }, 1000); } setContentView(R.layout.activity_main); // Get local Bluetooth adapter if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); else mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { showToast("Bluetooth is not available", Toast.LENGTH_LONG); finish(); return; } // get sensorManager and initialize sensor listeners SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorFusion = new SensorFusion(getApplicationContext(), mSensorManager); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the primary sections of the app. ViewPagerAdapter mViewPagerAdapter = new ViewPagerAdapter(getApplicationContext(), getSupportFragmentManager()); // Set up the ViewPager with the adapter. CustomViewPager mViewPager = (CustomViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mViewPagerAdapter); if (getResources().getBoolean(R.bool.isTablet)) mViewPager.setOffscreenPageLimit(2); // Since two fragments is selected in landscape mode, this is used to smooth things out // Bind the underline indicator to the adapter mUnderlinePageIndicator = (UnderlinePageIndicator) findViewById(R.id.indicator); mUnderlinePageIndicator.setViewPager(mViewPager); mUnderlinePageIndicator.setFades(false); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mUnderlinePageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (D) Log.d(TAG, "ViewPager position: " + position); if (position < actionBar.getTabCount()) // Needed for when in landscape mode actionBar.setSelectedNavigationItem(position); else mUnderlinePageIndicator.setCurrentItem(position - 1); } }); int count = mViewPagerAdapter.getCount(); Resources mResources = getResources(); boolean landscape = false; if (mResources.getBoolean(R.bool.isTablet) && mResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { landscape = true; count -= 1; // There is one less tab when in landscape mode } for (int i = 0; i < count; i++) { // For each of the sections in the app, add a tab to the action bar String text; if (landscape && i == count - 1) text = mViewPagerAdapter.getPageTitle(i) + " & " + mViewPagerAdapter.getPageTitle(i + 1); // Last tab in landscape mode have two titles in one tab else text = mViewPagerAdapter.getPageTitle(i).toString(); // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar.addTab(actionBar.newTab().setText(text).setTabListener(this)); } try { PackageManager mPackageManager = getPackageManager(); if (mPackageManager != null) BalanduinoActivity.appVersion = mPackageManager.getPackageInfo(getPackageName(), 0).versionName; // Read the app version name } catch (NameNotFoundException e) { e.printStackTrace(); } }
From source file:de.cachebox_test.splash.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!FileFactory.isInitial()) { new AndroidFileFactory(); }//w w w.j ava 2s .com requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.splash); DisplayMetrics displaymetrics = this.getResources().getDisplayMetrics(); GlobalCore.displayDensity = displaymetrics.density; int h = displaymetrics.heightPixels; int w = displaymetrics.widthPixels; int sw = h > w ? w : h; sw /= GlobalCore.displayDensity; // check if tablet GlobalCore.isTab = sw > 400 ? true : false; int dpH = (int) (h / GlobalCore.displayDensity + 0.5); int dpW = (int) (w / GlobalCore.displayDensity + 0.5); if (dpH * dpW >= 960 * 720) GlobalCore.displayType = DisplayType.xLarge; else if (dpH * dpW >= 640 * 480) GlobalCore.displayType = DisplayType.Large; else if (dpH * dpW >= 470 * 320) GlobalCore.displayType = DisplayType.Normal; else GlobalCore.displayType = DisplayType.Small; // berprfen, ob ACB im Hochformat oder Querformat gestartet wurde. // Hochformat -> Handymodus // Querformat -> Tablet-Modus if (w > h) isLandscape = true; // Portrt erzwingen wenn Normal oder Small display if (isLandscape && (GlobalCore.displayType == DisplayType.Normal || GlobalCore.displayType == DisplayType.Small)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } // chek if use small skin GlobalCore.useSmallSkin = GlobalCore.displayType == DisplayType.Small ? true : false; // chk if tabletLayout posible GlobalCore.posibleTabletLayout = (GlobalCore.displayType == DisplayType.xLarge || GlobalCore.displayType == DisplayType.Large); // get parameters final Bundle extras = getIntent().getExtras(); final Uri uri = getIntent().getData(); // try to get data from extras if (extras != null) { GcCode = extras.getString("geocode"); name = extras.getString("name"); guid = extras.getString("guid"); } // try to get data from URI if (GcCode == null && guid == null && uri != null) { String uriHost = uri.getHost().toLowerCase(); String uriPath = uri.getPath().toLowerCase(); // String uriQuery = uri.getQuery(); if (uriHost.contains("geocaching.com")) { GcCode = uri.getQueryParameter("wp"); guid = uri.getQueryParameter("guid"); if (GcCode != null && GcCode.length() > 0) { GcCode = GcCode.toUpperCase(); guid = null; } else if (guid != null && guid.length() > 0) { GcCode = null; guid = guid.toLowerCase(); } else { // warning.showToast(res.getString(R.string.err_detail_open)); finish(); return; } } else if (uriHost.contains("coord.info")) { if (uriPath != null && uriPath.startsWith("/gc")) { GcCode = uriPath.substring(1).toUpperCase(); } else { // warning.showToast(res.getString(R.string.err_detail_open)); finish(); return; } } } if (uri != null) { if (uri.getEncodedPath().endsWith(".gpx")) { GpxPath = uri.getEncodedPath(); } } // if ACB running, call this instance if (main.mainActivity != null) { Bundle b = new Bundle(); if (GcCode != null) { b.putSerializable("GcCode", GcCode); b.putSerializable("name", name); b.putSerializable("guid", guid); } if (GpxPath != null) { b.putSerializable("GpxPath", GpxPath); } Intent mainIntent = main.mainActivity.getIntent(); mainIntent.putExtras(b); startActivity(mainIntent); finish(); } splashActivity = this; LoadImages(); if (savedInstanceState != null) { mSelectDbIsStartet = savedInstanceState.getBoolean("SelectDbIsStartet"); mOriantationRestart = savedInstanceState.getBoolean("OriantationRestart"); } if (mOriantationRestart) return; // wait for result }
From source file:com.wearme.fat.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }/* ww w .ja v a 2s .c o m*/ this.requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setBehindContentView(R.layout.test); mContext = MainActivity.this; mDataBaseManager = DatabaseManager.getInstance(mContext); mInflater = getLayoutInflater(); initUserDataList(); initViewPager(); initSlideMenuView(); initShackListener(); mOptionsStyle = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.ic_launcher) .showImageForEmptyUri(R.drawable.ic_launcher).showImageOnFail(R.drawable.ic_launcher) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); mHandler = new Handler(); if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); finish(); } final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); if (mBluetoothAdapter == null) { Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); finish(); return; } Intent gattServiceIntent = new Intent(this, BluetoothLeService.class); getApplicationContext().bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); }
From source file:com.edutech.eBalanbot.eBalanbotActivity.java
@Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; context = getApplicationContext();//from w w w . ja v a 2 s.c om if (!getResources().getBoolean(R.bool.isTablet)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set portrait mode only - for small screens like phones else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); // Full screen rotation else setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); // Full screen rotation new Handler().postDelayed(new Runnable() { // Hack to hide keyboard when the layout it rotated @Override public void run() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Hide the keyboard - this is needed when the device is rotated imm.hideSoftInputFromWindow(getWindow().getDecorView().getApplicationWindowToken(), 0); } }, 1000); } setContentView(R.layout.activity_main); // Get local Bluetooth adapter if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); else mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { showToast("Bluetooth is not available", Toast.LENGTH_LONG); finish(); return; } // get sensorManager and initialize sensor listeners SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorFusion = new SensorFusion(getApplicationContext(), mSensorManager); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the primary sections of the app. ViewPagerAdapter mViewPagerAdapter = new ViewPagerAdapter(getApplicationContext(), getSupportFragmentManager()); // Set up the ViewPager with the adapter. CustomViewPager mViewPager = (CustomViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mViewPagerAdapter); if (getResources().getBoolean(R.bool.isTablet)) mViewPager.setOffscreenPageLimit(2); // Since two fragments is selected in landscape mode, this is used to smooth things out // Bind the underline indicator to the adapter mUnderlinePageIndicator = (UnderlinePageIndicator) findViewById(R.id.indicator); mUnderlinePageIndicator.setViewPager(mViewPager); mUnderlinePageIndicator.setFades(false); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mUnderlinePageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (D) Log.d(TAG, "ViewPager position: " + position); if (position < actionBar.getTabCount()) // Needed for when in landscape mode actionBar.setSelectedNavigationItem(position); else mUnderlinePageIndicator.setCurrentItem(position - 1); } }); int count = mViewPagerAdapter.getCount(); Resources mResources = getResources(); boolean landscape = false; if (mResources.getBoolean(R.bool.isTablet) && mResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { landscape = true; count -= 1; // There is one less tab when in landscape mode } for (int i = 0; i < count; i++) { // For each of the sections in the app, add a tab to the action bar String text; if (landscape && i == count - 1) text = mViewPagerAdapter.getPageTitle(i) + " & " + mViewPagerAdapter.getPageTitle(i + 1); // Last tab in landscape mode have two titles in one tab else text = mViewPagerAdapter.getPageTitle(i).toString(); // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar.addTab(actionBar.newTab().setText(text).setTabListener(this)); } try { PackageManager mPackageManager = getPackageManager(); if (mPackageManager != null) eBalanbotActivity.appVersion = mPackageManager.getPackageInfo(getPackageName(), 0).versionName; // Read the app version name } catch (NameNotFoundException e) { e.printStackTrace(); } }
From source file:com.kaichaohulian.baocms.ecdemo.ui.LauncherActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { int pid = android.os.Process.myPid(); Intent intentGroup = new Intent(); intentGroup.setAction("com.kaichaohulian.baocms.inited"); sendBroadcast(intentGroup);//from w ww . j a va2 s.c om if (mLauncherUI != null) { LogUtil.i(LogUtil.getLogUtilsTag(LauncherActivity.class), "finish last LauncherUI"); mLauncherUI.finish(); } // 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(); }