List of usage examples for android.content Intent removeExtra
public void removeExtra(String name)
From source file:org.voidsink.anewjkuapp.activity.KusssAuthenticatorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { UIUtils.applyTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); setSupportActionBar(toolbar);/*from ww w .j av a 2 s . co m*/ initActionBar(); mAccountManager = AccountManager.get(this); Intent mIntent = getIntent(); String accountName = null; Boolean mIsNewAccount = false; Account mAccount = AppUtils.getAccount(this); if (mAccount != null) { accountName = mAccount.name; if (mIntent != null) { mIntent.removeExtra(KusssAuthenticator.ARG_IS_ADDING_NEW_ACCOUNT); mIntent.putExtra(KusssAuthenticator.ARG_ACCOUNT_NAME, mAccount.name); mIntent.putExtra(KusssAuthenticator.ARG_ACCOUNT_TYPE, mAccount.type); } } else if (mIntent != null) { accountName = getIntent().getStringExtra(KusssAuthenticator.ARG_ACCOUNT_NAME); mIsNewAccount = mIntent.getBooleanExtra(KusssAuthenticator.ARG_IS_ADDING_NEW_ACCOUNT, false); if (!mIntent.hasExtra(KusssAuthenticator.ARG_ACCOUNT_TYPE)) { mIntent.putExtra(KusssAuthenticator.ARG_ACCOUNT_TYPE, KusssAuthenticator.ACCOUNT_TYPE); } } if (mAuthTokenType == null) { mAuthTokenType = KusssAuthenticator.AUTHTOKEN_TYPE_READ_ONLY; } if (!mIsNewAccount) { if (accountName != null) { final TextView tvAccountName = (TextView) findViewById(R.id.accountName); if (tvAccountName != null) { tvAccountName.setText(accountName); tvAccountName.setEnabled(false); } } } mSubmit = (Button) findViewById(R.id.accountLogin); mSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) && (ContextCompat.checkSelfPermission(KusssAuthenticatorActivity.this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED)) { new AlertDialog.Builder(KusssAuthenticatorActivity.this) .setMessage(R.string.alert_permission_get_accounts) .setPositiveButton(R.string.button_ok, null).setCancelable(false).show(); } else { submit(); } } }); }
From source file:ch.ethz.twimight.activities.UserListActivity.java
private void setInitialTab(Intent intent) { int initialPosition = 0; if (intent.hasExtra(EXTRA_KEY_INITIAL_TAB)) { String initialTab = intent.getStringExtra(EXTRA_KEY_INITIAL_TAB); if (EXTRA_INITIAL_TAB_FOLLOWING.equals(initialTab)) { initialPosition = 0;/*from w w w. j av a2 s.co m*/ } else if (EXTRA_INITIAL_TAB_FOLLOWERS.equals(initialTab)) { initialPosition = 1; } else if (EXTRA_INITIAL_TAB_PEERS.equals(initialTab)) { initialPosition = 2; } intent.removeExtra(EXTRA_KEY_INITIAL_TAB); } mViewPager.setCurrentItem(initialPosition); }
From source file:de.janniskilian.xkcdreader.presentation.components.showcomics.ShowComicsActivity.java
private void handleIntent(Intent intent) { if (intent.hasExtra("num")) { presenter.onComicSelected(intent.getIntExtra("num", 1)); intent.removeExtra("num"); }/*ww w . j ava2s . c o m*/ }
From source file:com.scoreflex.ScoreflexGcmClient.java
protected static boolean onBroadcastReceived(Context context, Intent intent, int iconResource, Class<? extends Activity> activity) { Bundle extras = intent.getExtras();/*from w ww . j a v a 2 s. c o m*/ if (extras.isEmpty()) { // has effect of unparcelling Bundle return false; } String customDataJson = extras.getString(SCOREFLEX_CUSTOM_DATA_EXTRA_KEY); if (null == customDataJson) { return false; } try { JSONObject customData = new JSONObject(customDataJson); JSONObject data = customData.getJSONObject(SCOREFLEX_NOTIFICATION_EXTRA_KEY); JSONObject sfxData = data.optJSONObject("data"); if (data.getInt("code") < Scoreflex.NOTIFICATION_TYPE_CHALLENGE_INVITATION) { return false; } String targetPlayerId = sfxData.optString("targetPlayerId"); String loggedPlayerId = ScoreflexRestClient.getPlayerId(context); if (!targetPlayerId.equals(loggedPlayerId)) { return false; } PendingIntent pendingIntent = buildPendingIntent(data, context, activity); Notification notification = buildNotification(extras.getString("alert"), context, iconResource, pendingIntent); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(data.getInt("code"), notification); intent.removeExtra(SCOREFLEX_CUSTOM_DATA_EXTRA_KEY); } catch (JSONException e1) { } return false; }
From source file:de.da_sense.moses.client.RunningFragment.java
@Override public void onResume() { super.onResume(); refreshInstalledApplications();//from w w w. jav a 2 s.com Intent startingIntent = mActivity.getIntent(); if (startingIntent.hasExtra(WelcomeActivity.KEY_VIEW_SURVEY)) { // some other activity has started the parent activity in order to show an available survey, show it god damn it String apkID = startingIntent.getStringExtra(WelcomeActivity.KEY_VIEW_SURVEY); startingIntent.removeExtra(WelcomeActivity.KEY_VIEW_SURVEY); // remove the extra from the intent because already processed // obtain the view responsible for the apk final Integer positionOfTheView = mApkPositions.get(apkID); if (positionOfTheView == null || installedApps.size() <= positionOfTheView) { // the could already be in history tab, for example when the user fills the survey and then // tries to fill it again by following the status bar notification Log.i(LOG_TAG, "onResume() the apk is no longer in the list, the user may have already filled the survey"); Toaster.showToast(mActivity, getString(R.string.notification_user_study_not_available)); } else { showDetails(positionOfTheView, mActivity, new Runnable() { @Override public void run() { handleStartApp(getInstalledApps().get(positionOfTheView)); } }, new Runnable() { @Override public void run() { } }); } } }
From source file:com.radioactiveyak.location_best_practices.UI.PlaceActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate the layout setContentView(R.layout.main);//from ww w . ja v a 2 s . c om // Get a handle to the Fragments placeListFragment = (PlaceListFragment) getSupportFragmentManager().findFragmentById(R.id.list_fragment); checkinFragment = (CheckinFragment) getSupportFragmentManager().findFragmentById(R.id.checkin_fragment); // Get references to the managers packageManager = getPackageManager(); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Get a reference to the Shared Preferences and a Shared Preference Editor. prefs = getSharedPreferences(PlacesConstants.SHARED_PREFERENCE_FILE, Context.MODE_PRIVATE); prefsEditor = prefs.edit(); // Instantiate a SharedPreferenceSaver class based on the available platform version. // This will be used to save shared preferences sharedPreferenceSaver = PlatformSpecificImplementationFactory.getSharedPreferenceSaver(this); // Save that we've been run once. prefsEditor.putBoolean(PlacesConstants.SP_KEY_RUN_ONCE, true); sharedPreferenceSaver.savePreferences(prefsEditor, false); // Specify the Criteria to use when requesting location updates while the application is Active criteria = new Criteria(); if (PlacesConstants.USE_GPS_WHEN_ACTIVITY_VISIBLE) criteria.setAccuracy(Criteria.ACCURACY_FINE); else criteria.setPowerRequirement(Criteria.POWER_LOW); // Setup the location update Pending Intents Intent activeIntent = new Intent(this, LocationChangedReceiver.class); locationListenerPendingIntent = PendingIntent.getBroadcast(this, 0, activeIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent passiveIntent = new Intent(this, PassiveLocationChangedReceiver.class); locationListenerPassivePendingIntent = PendingIntent.getBroadcast(this, 0, passiveIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Instantiate a LastLocationFinder class. // This will be used to find the last known location when the application starts. lastLocationFinder = PlatformSpecificImplementationFactory.getLastLocationFinder(this); lastLocationFinder.setChangedLocationListener(oneShotLastLocationUpdateListener); // Instantiate a Location Update Requester class based on the available platform version. // This will be used to request location updates. locationUpdateRequester = PlatformSpecificImplementationFactory.getLocationUpdateRequester(locationManager); // Create an Intent Filter to listen for checkins newCheckinReceiverName = new ComponentName(this, NewCheckinReceiver.class); newCheckinFilter = new IntentFilter(PlacesConstants.NEW_CHECKIN_ACTION); // Check to see if an Place ID has been specified in the launch Intent. // If so, we should display the details for the specified venue. if (getIntent().hasExtra(PlacesConstants.EXTRA_KEY_ID)) { Intent intent = getIntent(); String key = intent.getStringExtra(PlacesConstants.EXTRA_KEY_ID); if (key != null) { selectDetail(null, key); // Remove the ID from the Intent (so that a resume doesn't reselect). intent.removeExtra(PlacesConstants.EXTRA_KEY_ID); setIntent(intent); } } }
From source file:com.riverspart.location.ui.PlaceActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate the layout setContentView(R.layout.location_main); // Get a handle to the Fragments placeListFragment = (PlaceListFragment) getSupportFragmentManager().findFragmentById(R.id.list_fragment); checkinFragment = (CheckinFragment) getSupportFragmentManager().findFragmentById(R.id.checkin_fragment); // Get references to the managers packageManager = getPackageManager(); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Get a reference to the Shared Preferences and a Shared Preference Editor. prefs = getSharedPreferences(PlacesConstants.SHARED_PREFERENCE_FILE, Context.MODE_PRIVATE); prefsEditor = prefs.edit();/*from ww w .j a v a2 s . c om*/ // Instantiate a SharedPreferenceSaver class based on the available platform version. // This will be used to save shared preferences sharedPreferenceSaver = PlatformSpecificImplementationFactory.getSharedPreferenceSaver(this); // Save that we've been run once. prefsEditor.putBoolean(PlacesConstants.SP_KEY_RUN_ONCE, true); sharedPreferenceSaver.savePreferences(prefsEditor, false); // Specify the Criteria to use when requesting location updates while the application is Active criteria = new Criteria(); if (PlacesConstants.USE_GPS_WHEN_ACTIVITY_VISIBLE) criteria.setAccuracy(Criteria.ACCURACY_FINE); else criteria.setPowerRequirement(Criteria.POWER_LOW); // Setup the location update Pending Intents Intent activeIntent = new Intent(this, LocationChangedReceiver.class); locationListenerPendingIntent = PendingIntent.getBroadcast(this, 0, activeIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent passiveIntent = new Intent(this, PassiveLocationChangedReceiver.class); locationListenerPassivePendingIntent = PendingIntent.getBroadcast(this, 0, passiveIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Instantiate a LastLocationFinder class. // This will be used to find the last known location when the application starts. lastLocationFinder = PlatformSpecificImplementationFactory.getLastLocationFinder(this); lastLocationFinder.setChangedLocationListener(oneShotLastLocationUpdateListener); // Instantiate a Location Update Requester class based on the available platform version. // This will be used to request location updates. locationUpdateRequester = PlatformSpecificImplementationFactory.getLocationUpdateRequester(locationManager); // Create an Intent Filter to listen for checkins newCheckinReceiverName = new ComponentName(this, NewCheckinReceiver.class); newCheckinFilter = new IntentFilter(PlacesConstants.NEW_CHECKIN_ACTION); // Check to see if an Place ID has been specified in the launch Intent. // If so, we should display the details for the specified venue. if (getIntent().hasExtra(PlacesConstants.EXTRA_KEY_ID)) { Intent intent = getIntent(); String key = intent.getStringExtra(PlacesConstants.EXTRA_KEY_ID); if (key != null) { selectDetail(null, key); // Remove the ID from the Intent (so that a resume doesn't reselect). intent.removeExtra(PlacesConstants.EXTRA_KEY_ID); setIntent(intent); } } }
From source file:com.android.transmart.PlaceActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate the layout setContentView(R.layout.nearby);/*from w ww. j a va2s .c o m*/ // Get a handle to the Fragments placeListFragment = (PlaceListFragment) getSupportFragmentManager().findFragmentById(R.id.list_fragment); checkinFragment = (CheckinFragment) getSupportFragmentManager().findFragmentById(R.id.checkin_fragment); // Get references to the managers packageManager = getPackageManager(); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Get a reference to the Shared Preferences and a Shared Preference Editor. prefs = getSharedPreferences(LocationConstants.SHARED_PREFERENCE_FILE, Context.MODE_PRIVATE); prefsEditor = prefs.edit(); // Instantiate a SharedPreferenceSaver class based on the available platform version. // This will be used to save shared preferences sharedPreferenceSaver = PlatformSpecific.getSharedPreferenceSaver(this); // Save that we've been run once. prefsEditor.putBoolean(LocationConstants.SP_KEY_RUN_ONCE, true); sharedPreferenceSaver.savePreferences(prefsEditor, false); // Specify the Criteria to use when requesting location updates while the application is Active criteria = new Criteria(); if (LocationConstants.USE_GPS_WHEN_ACTIVITY_VISIBLE) criteria.setAccuracy(Criteria.ACCURACY_FINE); else criteria.setPowerRequirement(Criteria.POWER_LOW); // Setup the location update Pending Intents Intent activeIntent = new Intent(this, LocationChangedReceiver.class); locationListenerPendingIntent = PendingIntent.getBroadcast(this, 0, activeIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent passiveIntent = new Intent(this, PassiveLocReceiver.class); locationListenerPassivePendingIntent = PendingIntent.getBroadcast(this, 0, passiveIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Instantiate a LastLocationFinder class. // This will be used to find the last known location when the application starts. lastLocationFinder = PlatformSpecific.getLastLocationFinder(this); lastLocationFinder.setChangedLocationListener(oneShotLastLocationUpdateListener); // Instantiate a Location Update Requester class based on the available platform version. // This will be used to request location updates. locationUpdateRequester = PlatformSpecific.getLocationUpdateRequester(locationManager); // Create an Intent Filter to listen for checkins newCheckinReceiverName = new ComponentName(this, NewCheckinReceiver.class); newCheckinFilter = new IntentFilter(LocationConstants.NEW_CHECKIN_ACTION); // Check to see if an Place ID has been specified in the launch Intent. // If so, we should display the details for the specified venue. if (getIntent().hasExtra(LocationConstants.EXTRA_KEY_ID)) { Intent intent = getIntent(); String key = intent.getStringExtra(LocationConstants.EXTRA_KEY_ID); if (key != null) { selectDetail(null, key); // Remove the ID from the Intent (so that a resume doesn't reselect). intent.removeExtra(LocationConstants.EXTRA_KEY_ID); setIntent(intent); } } }
From source file:ch.ethz.twimight.activities.HomeScreenActivity.java
private void setSelectedTab(Intent intent) { int initialPosition = 0; if (intent.hasExtra(EXTRA_KEY_INITIAL_TAB)) { String initialTab = intent.getStringExtra(EXTRA_KEY_INITIAL_TAB); if (EXTRA_INITIAL_TAB_TIMELINE.equals(initialTab)) { initialPosition = 0;/*ww w . j a va 2s. c om*/ } else if (EXTRA_INITIAL_TAB_FAVORITES.equals(initialTab)) { initialPosition = 1; } else if (EXTRA_INITIAL_TAB_MENTIONS.equals(initialTab)) { initialPosition = 2; } intent.removeExtra(EXTRA_KEY_INITIAL_TAB); } mViewPager.setCurrentItem(initialPosition); setFragment(initialPosition); }
From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java
public void fireAlarm(Intent intent) throws InterruptedException { Context c = App.getContext(); if ((intent == null) || !intent.hasExtra("json")) { return;/*from w w w . ja v a2 s . co m*/ } Alarm next = Alarm.fromString(intent.getStringExtra("json")); intent.removeExtra("json"); if (next.city == 0) { return; } Times t = Times.getTimes(next.city); if (t == null) return; boolean active; if (next.cuma) { active = t.isCumaActive(); } else if (next.early) { active = t.isEarlyNotificationActive(next.vakit); } else { active = t.isNotificationActive(next.vakit); } if (!active) { return; } boolean vibrate; String sound; String dua; long silenter; if (next.cuma) { vibrate = t.hasCumaVibration(); sound = t.getCumaSound(); dua = "silent"; silenter = t.getCumaSilenterDuration(); } else if (next.early) { vibrate = t.hasEarlyVibration(next.vakit); sound = t.getEarlySound(next.vakit); dua = "silent"; silenter = t.getEarlySilenterDuration(next.vakit); } else { vibrate = t.hasVibration(next.vakit); sound = t.getSound(next.vakit); dua = t.getDua(next.vakit); silenter = t.getSilenterDuration(next.vakit); } NotificationManager nm = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(next.city + "", NotIds.ALARM); String text; text = t.getName() + " (" + t.getSource() + ")"; String txt = ""; if (next.early) { String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part); txt = App.getContext().getString(R.string.earlyText, left_part[next.vakit.index], "" + t.getEarlyTime(next.vakit)); } else if (next.cuma) { String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part); txt = App.getContext().getString(R.string.earlyText, left_part[next.vakit.index], "" + t.getCumaTime()); } else if (next.vakit != null) { txt = next.vakit.getString(); } NotificationCompat.Builder builder = new NotificationCompat.Builder(c).setContentTitle(text) .setContentText(txt).setContentIntent(Main.getPendingIntent(t)).setSmallIcon(R.drawable.ic_abicon); Notification not = builder.build(); if (vibrate) { not.vibrate = VibrationPreference.getPattern(c, "vibration"); } AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE); class MPHolder { MediaPlayer mp; } not.deleteIntent = PendingIntent.getBroadcast(c, 0, new Intent(c, Audio.class), PendingIntent.FLAG_UPDATE_CURRENT); nm.notify(next.city + "", NotIds.ALARM, not); final MPHolder mp = new MPHolder(); if (Prefs.showNotificationScreen() && (sound != null) && !sound.startsWith("silent")) { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (!pm.isScreenOn()) { Intent i = new Intent(c, NotificationPopup.class); i.putExtra("city", next.city); i.putExtra("name", text); i.putExtra("vakit", txt); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); c.startActivity(i); Thread.sleep(1000); } } sInterrupt = false; boolean hasSound = false; while ((sound != null) && !sound.startsWith("silent") && !sInterrupt) { int volume = -2; hasSound = true; if (!sound.startsWith("silent") && !sound.startsWith("picker")) { if (sound.contains("$volume")) { volume = Integer.parseInt(sound.substring(sound.indexOf("$volume") + 7)); sound = sound.substring(0, sound.indexOf("$volume")); } if (volume != -2) { int oldvalue = am.getStreamVolume(getStreamType(c)); am.setStreamVolume(getStreamType(c), volume, 0); volume = oldvalue; } try { mp.mp = play(c, sound); } catch (IOException e) { e.printStackTrace(); if (next.cuma) { t.setCumaSound("silent"); } else if (next.early) { t.setEarlySound(next.vakit, "silent"); } else { if ("sound".equals(t.getSound(next.vakit))) { t.setSound(next.vakit, "silent"); } else { t.setDua(next.vakit, "silent"); } } mp.mp = null; } if (mp.mp != null) { mp.mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { if (mp.mp == null) { return; } mp.mp.stop(); mp.mp.release(); mp.mp = null; } }); mp.mp.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() { @Override public void onSeekComplete(MediaPlayer mediaPlayer) { if (mp.mp == null) { return; } mp.mp.stop(); mp.mp.release(); mp.mp = null; } }); } sInterrupt = false; while ((mp.mp != null) && mp.mp.isPlaying()) { if (sInterrupt) { mp.mp.stop(); mp.mp.release(); mp.mp = null; dua = null; } else { try { Thread.sleep(500); } catch (InterruptedException ignore) { } } } sInterrupt = false; } if (volume != -2) { am.setStreamVolume(getStreamType(c), volume, 0); } sound = dua; dua = null; } if (hasSound && Prefs.autoRemoveNotification()) { nm.cancel(next.city + "", NotIds.ALARM); } if (silenter != 0) { silenter(c, silenter); } }