List of usage examples for android.os Bundle getInt
public int getInt(String key)
From source file:com.wirelessmoves.cl.MainActivity.java
@SuppressWarnings("deprecation") @Override/*from w ww.j ava2 s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* If saved variable state exists from last run, recover it */ if (savedInstanceState != null) { NumberOfSignalStrengthUpdates = savedInstanceState.getLong("NumberOfSignalStrengthUpdates"); LastCellId = savedInstanceState.getLong("LastCellId"); NumberOfCellChanges = savedInstanceState.getLong("NumberOfCellChanges"); LastLacId = savedInstanceState.getLong("LastLacId"); NumberOfLacChanges = savedInstanceState.getLong("NumberOfLacChanges"); PreviousCells = savedInstanceState.getLongArray("PreviousCells"); PreviousCellsIndex = savedInstanceState.getInt("PreviousCellsIndex"); NumberOfUniqueCellChanges = savedInstanceState.getLong("NumberOfUniqueCellChanges"); outputDebugInfo = savedInstanceState.getBoolean("outputDebugInfo"); CurrentLocationLong = savedInstanceState.getDouble("CurrentLocationLong"); CurrentLocationLat = savedInstanceState.getDouble("CurrentLocationLat"); /* attempt to restore the previous gps location information object */ PrevLocation = (Location) getLastNonConfigurationInstance(); } else { /* Initialize PreviousCells Array to defined values */ for (int x = 0; x < PreviousCells.length; x++) PreviousCells[x] = 0; } /* Get a handle to the telephony manager service */ /* A listener will be installed in the object from the onResume() method */ MyListener = new MyPhoneStateListener(); Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); /* get a handle to the power manager and set a wake lock so the screen saver * is not activated after a timeout */ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen"); /* Get a handle to the location system for getting GPS information */ locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); gpsListener = new myLocationListener(); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener); }
From source file:edu.stanford.mobisocial.dungbeetle.ImageGalleryActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); mCorralClient = CorralClient.getInstance(this); mFeedUri = getIntent().getData();// w w w.ja va 2 s . co m long hash = getIntent().getLongExtra("objHash", -1); if (hash == -1) { toast("No image to view!"); finish(); return; } DbObj obj = App.instance().getMusubi().objForHash(hash); if (obj == null) { toast("Image does not exist!"); finish(); return; } mInitialObjId = obj.getLocalId(); getSupportLoaderManager().initLoader(0, null, this); mGallery = new SlowGallery(this); mGallery.setBackgroundColor(Color.BLACK); addContentView(mGallery, CommonLayouts.FULL_SCREEN); if (savedInstanceState != null) { mInitialSelection = savedInstanceState.getInt("selection"); } }
From source file:com.cwp.cmoneycharge.activity.AddPayActivity.java
@Override public void onEvent(int eventType, Bundle params) { //?/* w w w .j ava 2 s . c o m*/ switch (eventType) { case EVENT_ERROR: String reason = params.get("reason") + ""; Log.d("Add", "EVENT_ERROR, " + reason); break; case VoiceRecognitionService.EVENT_ENGINE_SWITCH: int type = params.getInt("engine_type"); Log.d("Add", "*?" + (type == 0 ? "" : "")); break; } }
From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_blue); ActivityHelper.initialize(this); routeController = new RouteController(this); coordinates = new ArrayList<Path>(); trackerController = new TrackerController(this); Intent intent = getIntent();//from w ww . j a v a 2 s . c o m Bundle b = intent.getExtras(); mDevice = b.getParcelable(Homescreen.DEVICE_EXTRA); mDeviceUUID = UUID.fromString(b.getString(Homescreen.DEVICE_UUID)); mMaxChars = b.getInt(Homescreen.BUFFER_SIZE); Log.d(TAG, "Ready"); mBtnDisconnect = (Button) findViewById(R.id.btnDisconnect); mBtnSend = (Button) findViewById(R.id.btnSend); mBtnClear = (Button) findViewById(R.id.btnClear); mTxtReceive = (TextView) findViewById(R.id.txtReceive); mEditSend = (EditText) findViewById(R.id.editSend); scrollView = (ScrollView) findViewById(R.id.viewScroll); chkScroll = (CheckBox) findViewById(R.id.chkScroll); chkReceiveText = (CheckBox) findViewById(R.id.chkReceiveText); checkBoxJoystickEnable = (CheckBox) findViewById(R.id.checkBoxJoystickEnable); mBtnClearInput = (Button) findViewById(R.id.btnClearInput); mBtnConfig = (Button) findViewById(R.id.buttonConfig2); //imageButtonClaw (Button)findViewById(R.id.imageButtonClaw); editTextAngle = (TextView) findViewById(R.id.editTextAngle); joystickView = (JoystickView) findViewById(R.id.viewJoystick); //Event listener that always returns the variation of the angle in degrees, motion power in percentage and direction of movement ibClaw = (ImageButton) findViewById(R.id.imageButtonClaw); clawControll = new ClawControll(ibClaw); joystickView.setOnJoystickMoveListener(new OnJoystickMoveListener() { @Override public void onValueChanged(int angle, int power, int direction) { // TODO Auto-generated method stub mTxtReceive.append(" " + String.valueOf(angle) + ""); mTxtReceive.append(" " + String.valueOf(power) + "%"); switch (direction) { case JoystickView.FRONT: mTxtReceive.append("FRONT"); sendSerial("a"); break; case JoystickView.FRONT_RIGHT: mTxtReceive.append("FRONT_RIGHT"); sendSerial("c"); break; case JoystickView.RIGHT: mTxtReceive.append("RIGHT"); sendSerial("c"); break; case JoystickView.RIGHT_BOTTOM: mTxtReceive.append("RIGHT_BOTTOM"); sendSerial("f"); break; case JoystickView.BOTTOM: mTxtReceive.append("BOTTOM"); sendSerial("d"); break; case JoystickView.BOTTOM_LEFT: mTxtReceive.append("BOTTOM_LEFT"); sendSerial("e"); break; case JoystickView.LEFT: mTxtReceive.append("LEFT"); sendSerial("b"); break; case JoystickView.LEFT_FRONT: mTxtReceive.append("LEFT_FRONT"); sendSerial("b"); break; default: mTxtReceive.append("CENTER"); sendSerial("g"); } } }, JoystickView.DEFAULT_LOOP_INTERVAL); mTxtReceive.setMovementMethod(new ScrollingMovementMethod()); mBtnDisconnect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mIsUserInitiatedDisconnect = true; new DisConnectBT().execute(); } }); mBtnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mBTSocket.getOutputStream().write(mEditSend.getText().toString().getBytes()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mBtnClear.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mEditSend.setText(""); } }); mBtnClearInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { //mTxtReceive.setText(""); if (mBtnClearInput.getText().toString().equalsIgnoreCase(LocationManager.GPS_PROVIDER)) { mBtnClearInput.setText(LocationManager.NETWORK_PROVIDER); gps.setProvider(LocationManager.NETWORK_PROVIDER); } else { mBtnClearInput.setText(LocationManager.GPS_PROVIDER); gps.setProvider(LocationManager.GPS_PROVIDER); } } }); mBtnConfig.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent(MainActivity.this, ConfigActivity.class); startActivity(i); } }); ibClaw.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (clawControll != null) { clawControll.changeState(); } } }); checkBoxJoystickEnable.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (checkBoxJoystickEnable.isChecked()) { joystickEnabled = true; joystickView.setEnabled(true); ibClaw.setEnabled(true); } else { joystickEnabled = false; joystickView.setEnabled(false); ibClaw.setEnabled(false); } } }); joystickView.setEnabled(true); ibClaw.setEnabled(true); initGPSListener(); // initialize your android device sensor capabilities mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); image = (ImageView) findViewById(R.id.compassImg); }
From source file:com.dvn.vindecoder.ui.seller.AddVehicalAndPayment.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView( R.layout.activity_add_vehical_and_payment); drawChildLayout();//from ww w .j a va 2s . co m setTitle("Add Vehical"); Bundle bundle = getIntent().getExtras(); // addNewVehicalFragment=new AddNewVehicalFragment(this); boolean scanFlag = false; if (bundle != null) { scanFlag = bundle.getBoolean("boolean"); } if (savedInstanceState == null) { // Do first time initialization -- add initial fragment. addNewVehicalFragment = AddNewVehicalFragment.newInstance(this, scanFlag); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.fragment1, addNewVehicalFragment).commit(); } else { mStackLevel = savedInstanceState.getInt("level"); } collapsing_toolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); /* toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);*/ }
From source file:com.markupartist.sthlmtraveling.PlannerFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // If the activity was started with the "create shortcut" action, we // remember this to change the behavior upon a search. if (Intent.ACTION_CREATE_SHORTCUT.equals(getActivity().getIntent().getAction())) { mCreateShortcut = true;//from ww w . j a va2s.c o m } if (savedInstanceState != null) { mStackLevel = savedInstanceState.getInt("level"); } CursorLoader cursorLoader = new CursorLoader(getActivity(), Journeys.CONTENT_URI, PROJECTION, null, //selection, null, //selectionArgs, Journeys.HISTORY_SORT_ORDER); Cursor cursor = cursorLoader.loadInBackground(); mAdapter = new JourneyAdapter(getActivity(), cursor); }
From source file:com.fsm.storybook.launcher.WebViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_view); context = this; bkdb = new BookDatabase(getApplicationContext()); globalApp = (GlobalApplication) this.getApplicationContext(); util = new ActivityUtil(this); currentOrientation = String.valueOf(util.getScreenOrientation()); gestureListener = new ContentGestureListener(this); //gestureListener = new WebViewGestureDetector(); mWebview = (WebView) findViewById(R.id.webview); //mWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mWebview.setOnClickListener(WebViewActivity.this); mWebview.setOnTouchListener(gestureListener); //mHiddenWebview = (WebView) findViewById(R.id.webview_hidden); //mHiddenWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mPageInfo = (TextView) findViewById(R.id.page_info); mPageSlider = (SeekBar) findViewById(R.id.page_slider); mPageSlider.setOnSeekBarChangeListener(this); mPageInfo.setVisibility(View.GONE); mPageSlider.setVisibility(View.GONE); Intent intent = getIntent();/*from w ww. j a va 2s.c o m*/ Bundle extras = intent.getExtras(); if (extras == null) return; //if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) { mContainer = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID)); if (mContainer == null) { finish(); return; } mPackage = mContainer.getDefaultPackage(); //? int bookCode = extras.getInt(Constants.BOOK_CODE); mBookData = bkdb.fetchBook(bookCode); setTitle(mBookData.getTitle()); //??spineitem?spineitem?? List<SpineItem> spineItems = mPackage.getSpineItems(); for (SpineItem item : spineItems) { String idref = item.getIdRef(); mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_PORTRAIT), idref, 1); mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_LANDSCAPE), idref, 1); } bkdb.updateBook(mBookData); /* mBookmarkList = bkdb.fetchBookmarkList(bookCode); mHighlightList = bkdb.fetchHighlightList(bookCode); */ mViewerSettings = new ViewerSettings(mBookData.getSpreadCount() == 2, mBookData.getFontSize(), 20); try { Log.d(TAG, "openPageRequest JSON:" + extras.getString(Constants.OPEN_PAGE_REQUEST_DATA)); mOpenPageRequestData = OpenPageRequest.fromJSON(extras.getString(Constants.OPEN_PAGE_REQUEST_DATA)); } catch (JSONException e) { Log.e(TAG, "Constants.OPEN_PAGE_REQUEST_DATA must be a valid JSON object: " + e.getMessage(), e); } //??? if (mBookData.getTotalPageCount(currentOrientation) <= 0) { pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_NONE; } else { pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_DONE; } //epub web server new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { mServer = new EpubServer(EpubServer.HTTP_HOST, EpubServer.HTTP_PORT, mPackage, false); mServer.startServer(); return null; } }.execute(); //??hidden webview /* initHiddenWebView(); mHiddenWebview.loadUrl(HIDDEN_READER_SKELETON); mReadiumJSApiForHiddenWebView = new ReadiumJSApi(new ReadiumJSApi.JSLoader() { @Override public void loadJS(String javascript) { mHiddenWebview.loadUrl(javascript); } }); */ //?webview initWebView(); mWebview.loadUrl(READER_SKELETON); mReadiumJSApi = new ReadiumJSApi(new ReadiumJSApi.JSLoader() { @Override public void loadJS(String javascript) { mWebview.loadUrl(javascript); } }); //} }
From source file:github.popeen.dsub.activity.SubsonicActivity.java
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); int size = savedInstanceState.getInt(Constants.MAIN_BACK_STACK_SIZE); String[] ids = savedInstanceState.getStringArray(Constants.MAIN_BACK_STACK); FragmentManager fm = getSupportFragmentManager(); currentFragment = (SubsonicFragment) fm.findFragmentByTag(ids[0]); currentFragment.setPrimaryFragment(true); currentFragment.setSupportTag(ids[0]); supportInvalidateOptionsMenu();/*from w ww . j a v a2s. c o m*/ FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); for (int i = 1; i < size; i++) { SubsonicFragment frag = (SubsonicFragment) fm.findFragmentByTag(ids[i]); frag.setSupportTag(ids[i]); if (secondaryContainer != null) { frag.setPrimaryFragment(false, true); } trans.hide(frag); backStack.add(frag); } trans.commit(); // Current fragment is hidden in secondaryContainer if (secondaryContainer == null && !currentFragment.isVisible()) { trans = getSupportFragmentManager().beginTransaction(); trans.remove(currentFragment); trans.commit(); getSupportFragmentManager().executePendingTransactions(); trans = getSupportFragmentManager().beginTransaction(); trans.add(R.id.fragment_container, currentFragment, ids[0]); trans.commit(); } // Current fragment needs to be moved over to secondaryContainer else if (secondaryContainer != null && secondaryContainer.findViewById(currentFragment.getRootId()) == null && backStack.size() > 0) { trans = getSupportFragmentManager().beginTransaction(); trans.remove(currentFragment); trans.show(backStack.get(backStack.size() - 1)); trans.commit(); getSupportFragmentManager().executePendingTransactions(); trans = getSupportFragmentManager().beginTransaction(); trans.add(R.id.fragment_second_container, currentFragment, ids[0]); trans.commit(); secondaryContainer.setVisibility(View.VISIBLE); } lastSelectedPosition = savedInstanceState.getInt(Constants.FRAGMENT_POSITION); if (lastSelectedPosition != 0) { MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition); if (item != null) { item.setChecked(true); } } recreateSpinner(); checkIfServerOutdated(); }
From source file:com.irccloud.android.activity.PastebinsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));//from www . ja v a 2 s . c o m cloud.recycle(); } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("adapter")) { try { page = savedInstanceState.getInt("page"); Pastebin[] pastebins = (Pastebin[]) savedInstanceState.getSerializable("adapter"); for (Pastebin p : pastebins) { adapter.addPastebin(p); } adapter.notifyDataSetChanged(); } catch (Exception e) { page = 0; adapter.clear(); } } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchPastebinsTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final Pastebin p = (Pastebin) adapter.getItem(i); Intent intent = new Intent(PastebinsActivity.this, PastebinViewerActivity.class); intent.setData(Uri.parse(p.url + "?id=" + p.id + "&own_paste=" + (p.own_paste ? "1" : "0"))); startActivity(intent); } }); Toast.makeText(this, "Tap a pastebin to view full text with syntax highlighting", Toast.LENGTH_LONG).show(); }
From source file:jp.mixi.android.sdk.MixiContainerImpl.java
/** * ?/*ww w. j a va2 s.c o m*/ * * @throws RemoteException * @throws ApiException */ private synchronized void refreshToken() throws RemoteException, ApiException { Log.v(TAG, "refreshToken start"); Bundle bundle = new Bundle(); bundle.putString(REFRESH_TOKEN, getRefreshToken()); bundle.putString(CLIENT_ID, mClientId); // ????? if (mRemoteAuth == null) { Log.v(TAG, "RemoteAuthenticator is not bind"); throw new ApiException(ErrorInfo.OFFICIAL_APP_NOT_FOUND, "RemoteAuthenticator is not bind"); } Bundle response = mRemoteAuth.tokenRefresh(bundle); if (response.containsKey(ERROR_STR)) { Log.w(TAG, response.getString(ERROR_STR)); throw new ApiException(response.getInt(ERROR_CODE_STR), response.getString(ERROR_MESSAGE_STR)); } String accessToken = response.getString(ACCESS_TOKEN); String refreshToken = response.getString(REFRESH_TOKEN); String expire = response.getString(EXPIRES); setAccessToken(accessToken); setRefreshToken(refreshToken); setAccessExpiresIn(expire); if (mContextWrapper != null) { saveSession(mContextWrapper); } }