List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.javadog.cgeowear.cgeoWear.java
/** * Initializes the screen, whether the Activity was freshly-launched or onNewIntent was run. * * @param i The launch intent./* w w w. ja v a 2 s . com*/ */ private void initScreen(Intent i) { String cacheName = i.getStringExtra(MessageDataSet.KEY_CACHE_NAME); String geocode = i.getStringExtra(MessageDataSet.KEY_GEOCODE); distance = i.getFloatExtra(MessageDataSet.KEY_DISTANCE, 0f); direction = i.getFloatExtra(MessageDataSet.KEY_DIRECTION, 0f); geocacheLocation = i.getParcelableExtra(MessageDataSet.KEY_CACHE_LOCATION); //Start listening for compass updates, if the user wants useWatchCompass = i.getBooleanExtra(MessageDataSet.KEY_WATCH_COMPASS, false); if (accelerometer != null && magnetometer != null) { sensorManager.unregisterListener(this, accelerometer); sensorManager.unregisterListener(this, magnetometer); } Log.d(DEBUG_TAG, useWatchCompass ? "Using watch compass." : "Using phone compass."); if (useWatchCompass) { sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); magnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, magnetometer, SensorManager.SENSOR_DELAY_NORMAL); } tv_cacheName.setText(cacheName); tv_geocode.setText(geocode); setDistanceFormatted(distance); rotateCompass(direction); }
From source file:com.android.packageinstaller.PackageInstallerActivity.java
private boolean isInstallRequestFromUnknownSource(Intent intent) { String callerPackage = getCallingPackage(); if (callerPackage != null && intent.getBooleanExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false)) { try {//from w w w.j av a 2 s . com mSourceInfo = mPm.getApplicationInfo(callerPackage, 0); if (mSourceInfo != null) { if ((mSourceInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) { // Privileged apps are not considered an unknown source. return false; } } } catch (NameNotFoundException e) { } } return true; }
From source file:com.binomed.showtime.android.screen.movie.CineShowTimeMovieFragment.java
@Override public void onResume() { super.onResume(); Intent intent = interaction.getIntentMovie(); String movieId = null;/*from w ww . j av a2 s.c om*/ String theaterId = null; boolean fromWidget = intent.getBooleanExtra(ParamIntent.ACTIVITY_MOVIE_FROM_WIDGET, false); String near = intent.getStringExtra(ParamIntent.ACTIVITY_MOVIE_NEAR); Log.i(TAG, "From Widget : " + fromWidget); MovieBean movie = null; TheaterBean theater = null; // if (fromWidget) { // // Object[] currentMovie = extractCurrentMovie(); // if (currentMovie != null) { // theater = (TheaterBean) currentMovie[0]; // movie = (MovieBean) currentMovie[1]; // } // } else { movieId = intent.getStringExtra(ParamIntent.MOVIE_ID); movie = intent.getParcelableExtra(ParamIntent.MOVIE); theaterId = intent.getStringExtra(ParamIntent.THEATER_ID); theater = intent.getParcelableExtra(ParamIntent.THEATER); double latitude = intent.getDoubleExtra(ParamIntent.ACTIVITY_MOVIE_LATITUDE, -1); double longitude = intent.getDoubleExtra(ParamIntent.ACTIVITY_MOVIE_LONGITUDE, -1); if ((latitude != -1) && (longitude != -1)) { Location gpsLocation = new Location("GPS"); //$NON-NLS-1$ gpsLocation.setLatitude(latitude); gpsLocation.setLongitude(longitude); model.setGpsLocation(gpsLocation); } else { model.setGpsLocation(null); } // } Log.i(TAG, "Movie ID : " + movieId); model.setMovie(movie); moviePagedAdapter.changeData(movie, interaction.getMainContext(), model, tracker, this); moviePagedAdapter.notifyDataSetChanged(); if (theaterId != null) { model.setTheater(theater); } moviePagedAdapter.manageViewVisibility(); try { moviePagedAdapter.fillBasicInformations(movie); if (isServiceRunning()) { interaction.openDialog(); } if (movie.getImdbId() == null) { tracker.trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_MOVIE // Category , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action , CineShowtimeCst.ANALYTICS_LABEL_MOVIE_REUSE + 0 // Label , 0 // Value ); searchMovieDetail(movie, near); } else { tracker.trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_MOVIE // Category , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action , CineShowtimeCst.ANALYTICS_LABEL_MOVIE_REUSE + 1 // Label , 0 // Value ); moviePagedAdapter.fillViews(movie); } } catch (Exception e) { Log.e(TAG, "error on create", e); //$NON-NLS-1$ } }
From source file:com.phonemetra.deskclock.timer.TimerFragment.java
@Override public void onResume() { super.onResume(); if (getActivity() instanceof DeskClock) { DeskClock activity = (DeskClock) getActivity(); activity.registerPageChangedListener(this); }/*from w w w . j a va2 s . c o m*/ if (mAdapter == null) { mAdapter = new TimerFragmentAdapter(getChildFragmentManager(), mPrefs); } mAdapter.populateTimersFromPref(); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(mOnPageChangeListener); mPrefs.registerOnSharedPreferenceChangeListener(this); // Clear the flag set in the notification and alert because the adapter was just // created and is thus in sync with the database final SharedPreferences.Editor editor = mPrefs.edit(); if (mPrefs.getBoolean(Timers.FROM_NOTIFICATION, false)) { editor.putBoolean(Timers.FROM_NOTIFICATION, false); } if (mPrefs.getBoolean(Timers.FROM_ALERT, false)) { editor.putBoolean(Timers.FROM_ALERT, false); } editor.apply(); mCancel.setVisibility(mAdapter.getCount() == 0 ? View.INVISIBLE : View.VISIBLE); boolean goToSetUpView; // Process extras that were sent to the app and were intended for the timer fragment final Intent newIntent = getActivity().getIntent(); if (newIntent != null && newIntent.getBooleanExtra(TimerFullScreenFragment.GOTO_SETUP_VIEW, false)) { goToSetUpView = true; } else { if (mViewState != null) { final int currPage = mViewState.getInt(CURR_PAGE); mViewPager.setCurrentItem(currPage); highlightPageIndicator(currPage); final boolean hasPreviousInput = mViewState.getBoolean(KEY_SETUP_SELECTED, false); goToSetUpView = hasPreviousInput || mAdapter.getCount() == 0; mSetupView.restoreEntryState(mViewState, KEY_ENTRY_STATE); } else { highlightPageIndicator(0); // If user was not previously using the setup, determine which view to go by count goToSetUpView = mAdapter.getCount() == 0; } } if (goToSetUpView) { goToSetUpView(); } else { goToPagerView(); } }
From source file:com.example.recordvoice.service.RecordService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(Constants.TAG, "RecordService onStartCommand"); if (intent != null) { int commandType = intent.getIntExtra("commandType", 0); Log.d("LogMain", commandType + ""); if (commandType != 0) { if (commandType == Constants.RECORDING_ENABLED) { Log.d(Constants.TAG, "RecordService RECORDING_ENABLED"); silentMode = intent.getBooleanExtra("silentMode", true); if (!silentMode && phoneNumber != null && onCall && !recording) commandType = Constants.STATE_START_RECORDING; } else if (commandType == Constants.RECORDING_DISABLED) { Log.d(Constants.TAG, "RecordService RECORDING_DISABLED"); silentMode = intent.getBooleanExtra("silentMode", true); if (onCall && phoneNumber != null && recording) commandType = Constants.STATE_STOP_RECORDING; }/*w w w . j a v a2s . com*/ if (commandType == Constants.STATE_INCOMING_NUMBER) { Log.d(Constants.TAG, "RecordService STATE_INCOMING_NUMBER"); if (phoneNumber == null) phoneNumber = intent.getStringExtra("phoneNumber"); Log.d("LogMainphone", phoneNumber + "/m"); silentMode = intent.getBooleanExtra("silentMode", true); if (!silentMode && !(phoneNumber.charAt(0) == '*')) { startService(); } type = intent.getStringExtra("type"); } else if (commandType == Constants.STATE_CALL_START) { Log.d(Constants.TAG, "RecordService STATE_CALL_START"); onCall = true; Log.d("LogMain", silentMode + " " + phoneNumber + " " + recording + " /,m"); if (!silentMode && phoneNumber != null && onCall && !recording && !(phoneNumber.charAt(0) == '*')) { Log.d(Constants.TAG, "RecordService STATE_CALL_START1"); startService(); startRecording(intent); } } else if (commandType == Constants.STATE_CALL_END) { Log.d(Constants.TAG, "RecordService STATE_CALL_END"); onCall = false; phoneNumber = null; stopAndReleaseRecorder(); recording = false; stopService(); } else if (commandType == Constants.STATE_START_RECORDING) { Log.d(Constants.TAG, "RecordService STATE_START_RECORDING"); if (!silentMode && phoneNumber != null && onCall) { startService(); startRecording(intent); } } else if (commandType == Constants.STATE_STOP_RECORDING) { Log.d(Constants.TAG, "RecordService STATE_STOP_RECORDING"); stopAndReleaseRecorder(); recording = false; } } } return super.onStartCommand(intent, flags, startId); }
From source file:com.swetha.easypark.DisplayVacantParkingLots.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mapviewlistvacantparkinglots); Intent displayIntent = getIntent(); double usersCurrentLatitude = displayIntent.getDoubleExtra(GetParkingLots.LATITUDE, Constants.doubleDefaultValue); double usersCurrentLongitude = displayIntent.getDoubleExtra(GetParkingLots.LONGITUDE, Constants.doubleDefaultValue); fromTime = displayIntent.getLongExtra(GetParkingLots.FROMTIME, 0); toTime = displayIntent.getLongExtra(GetParkingLots.TOTIME, 0); isRadius = displayIntent.getBooleanExtra(GetParkingLots.RadiusOrZIPCODE, false); if (isRadius) { radius = displayIntent.getDoubleExtra(GetParkingLots.RADIUS, 0.0); } else {/* w ww. ja va 2 s.c o m*/ zipcode = displayIntent.getLongExtra(GetParkingLots.ZIPCODE, 0); } Log.i("DisplayVacantParkingLots", "Before Calling Async task"); new GetParkingLotsFromWebService(this, usersCurrentLatitude, usersCurrentLongitude, fromTime, toTime) .execute(); Log.i("DisplayVacantParkingLots", "After Calling Async task"); btn_switchToListView = (Button) findViewById(R.id.switchtolistview); btn_switchToListView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (parkingLotsMapList != null) // fixed crashing of application when no parking data found { Intent intent = new Intent(DisplayVacantParkingLots.this, DisplayParkingLotsAsList.class); intent.putExtra(ARRAYLISTMAP, parkingLotsMapList); startActivity(intent); } } }); }
From source file:com.bangz.shotrecorder.RecordActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recorder); ActionBar bar = getSupportActionBar(); bar.setDisplayHomeAsUpEnabled(true); strModeNames = getResources().getStringArray(R.array.mode_names); strModeValNames = getResources().getStringArray(R.array.mode_value_names); mMode = MODE.COMSTOCK;// www . j a v a 2s .c o m setDigitFont(); initButtonsListener(); TextView v = (TextView) findViewById(R.id.textTIME); v.setText("------"); FragmentManager fm = getSupportFragmentManager(); SplitListFragment splitfragment = (SplitListFragment) fm.findFragmentById(R.id.splitlist); mSplitAdapter = new SplitArrayAdapter(this, mSplitManager.getSplits()); splitfragment.setListAdapter(mSplitAdapter); if (savedInstanceState == null) { Intent intent = getIntent(); if (intent.getBooleanExtra(EXTRA_STARTFROMNOTIFY, false)) { mState = STATE_RECORDING; int mode = intent.getIntExtra(RecordService.EXTRA_MODE, 0); Log.d(TAG, "get mode in RecordActivity from service mode = " + mode); mMode = MODE.values()[mode]; mSampleRate = intent.getIntExtra(RecordService.EXTRA_SAMPLERATE, 44100); mChannels = intent.getIntExtra(RecordService.EXTRA_CHANNLES, AudioFormat.CHANNEL_IN_MONO); mEncoding = intent.getIntExtra(RecordService.EXTRA_ENCODDING, AudioFormat.ENCODING_PCM_16BIT); mMaxShots = intent.getIntExtra(RecordService.EXTRA_MAXSHOT, 0); mMaxParTime = intent.getIntExtra(RecordService.EXTRA_MAXPARTIME, 0) / 1000.0f; mCaptureSize = intent.getIntExtra(RecordService.EXTRA_CAPTURESIZE, 0); mMaxRecordTime = intent.getIntExtra(RecordService.EXTRA_MAXRECORDTIME, 5 * 60); } } updateMode(); updateStatus(); }
From source file:com.nicolatesser.geofencedemo.LocationActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // getIntent() should always return the most recent setIntent(intent);/*from w ww.java2 s . com*/ boolean receiverStarted = intent.getBooleanExtra("RECEIVER_STARTED", false); if (!receiverStarted) { return; } Bundle bundle = intent.getParcelableExtra("geo_fences"); ArrayList<String> requestIds = bundle.getStringArrayList("request_ids"); if (requestIds == null) { Log.v(LocationActivity.TAG, "request_ids == null"); return; } int transition = intent.getIntExtra("transition", -2); for (String requestId : requestIds) { Log.v(LocationActivity.TAG, "Triggering Geo Fence requestId " + requestId); if (transition == Geofence.GEOFENCE_TRANSITION_ENTER) { Circle circle = mGeoFences.get(requestId); if (circle == null) { continue; } Log.v(LocationActivity.TAG, "triggering_geo_fences enter == " + requestId); // Add a superimposed red circle when a geofence is entered and // put the corresponding object in triggering_fences. CircleOptions circleOptions = new CircleOptions(); circleOptions.center(circle.getCenter()).radius(circle.getRadius()) .fillColor(Color.argb(100, 100, 0, 0)); Circle newCircle = mMap.addCircle(circleOptions); mTriggeringFences.put(requestId, newCircle); // LocationLoggerService.getInstance().writeActivity( // DemoConstant.NAME, "Entered in Geofence"); } else if (transition == Geofence.GEOFENCE_TRANSITION_EXIT) { Log.v(LocationActivity.TAG, "triggering_geo_fences exit == " + requestId); Circle circle = mTriggeringFences.get(requestId); if (circle == null) { continue; } // Remove the superimposed red circle from the map and the // corresponding Circle object from triggering_fences hash_map. circle.remove(); mTriggeringFences.remove(requestId); // LocationLoggerService.getInstance().writeActivity( // DemoConstant.NAME, "Exited from Geofence"); } } return; }
From source file:com.jefftharris.passwdsafe.LauncherRecordShortcuts.java
@Override public void onCreate(Bundle savedInstanceState) { PasswdSafeApp.setupDialogTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher_record_shortcuts); SharedPreferences prefs = Preferences.getSharedPrefs(this); prefs.registerOnSharedPreferenceChangeListener(this); itsFile = (TextView) findViewById(R.id.file); itsFileDataView.onAttach(this, prefs); Intent intent = getIntent(); switch (intent.getAction()) { case Intent.ACTION_CREATE_SHORTCUT: { setTitle(R.string.shortcut_record); itsMode = Mode.SHORTCUT;/*from w ww .j av a2s .c o m*/ break; } case PasswdSafeApp.CHOOSE_RECORD_INTENT: { setTitle(R.string.choose_record); itsMode = Mode.CHOOSE_RECORD; GuiUtils.setVisible(itsFile, false); break; } default: { finish(); return; } } int options = PasswdRecordFilter.OPTS_DEFAULT; if (intent.getBooleanExtra(FILTER_NO_ALIAS, false)) { options |= PasswdRecordFilter.OPTS_NO_ALIAS; } if (intent.getBooleanExtra(FILTER_NO_SHORTCUT, false)) { options |= PasswdRecordFilter.OPTS_NO_SHORTCUT; } if (options != PasswdRecordFilter.OPTS_DEFAULT) { itsFileDataView.setRecordFilter(new PasswdRecordFilter(null, options)); } if (savedInstanceState == null) { FragmentManager fragMgr = getSupportFragmentManager(); FragmentTransaction txn = fragMgr.beginTransaction(); txn.replace(R.id.contents, PasswdSafeListFragment.newInstance(itsLocation, true)); txn.commit(); } }
From source file:com.betterAlarm.deskclock.timer.TimerFragment.java
@Override public void onResume() { super.onResume(); if (getActivity() instanceof DeskClock) { DeskClock activity = (DeskClock) getActivity(); activity.registerPageChangedListener(this); }/*from w ww . j a v a 2s .c o m*/ if (mAdapter == null) { mAdapter = new TimerFragmentAdapter(getChildFragmentManager(), mPrefs); } mAdapter.populateTimersFromPref(); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(mOnPageChangeListener); mPrefs.registerOnSharedPreferenceChangeListener(this); // Clear the flag set in the notification and alert because the adapter was just // created and is thus in sync with the database final SharedPreferences.Editor editor = mPrefs.edit(); if (mPrefs.getBoolean(Timers.FROM_NOTIFICATION, false)) { editor.putBoolean(Timers.FROM_NOTIFICATION, false); } if (mPrefs.getBoolean(Timers.FROM_ALERT, false)) { editor.putBoolean(Timers.FROM_ALERT, false); } editor.apply(); mCancel.setVisibility(mAdapter.getCount() == 0 ? View.INVISIBLE : View.VISIBLE); boolean goToSetUpView; // Process extras that were sent to the app and were intended for the timer fragment final Intent newIntent = getActivity().getIntent(); if (newIntent != null && newIntent.getBooleanExtra(TimerFullScreenFragment.GOTO_SETUP_VIEW, false)) { goToSetUpView = true; } else if (newIntent != null && newIntent.getBooleanExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, false)) { // We use this extra to identify if a. this activity is launched from api call, // and b. this fragment is resumed for the first time. If both are true, // we should show the timer view instead of setup view. goToSetUpView = false; // Show the first timer because that's the newly created one highlightPageIndicator(0); mViewPager.setCurrentItem(0); // Reset the extra to false to ensure when next time the fragment resume, // we no longer care if it's from api call or not. newIntent.putExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, false); } else { if (mViewState != null) { final int currPage = mViewState.getInt(CURR_PAGE); mViewPager.setCurrentItem(currPage); highlightPageIndicator(currPage); final boolean hasPreviousInput = mViewState.getBoolean(KEY_SETUP_SELECTED, false); goToSetUpView = hasPreviousInput || mAdapter.getCount() == 0; mSetupView.restoreEntryState(mViewState, KEY_ENTRY_STATE); } else { highlightPageIndicator(0); // If user was not previously using the setup, determine which view to go by count goToSetUpView = mAdapter.getCount() == 0; } } if (goToSetUpView) { goToSetUpView(); } else { goToPagerView(); } }