List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:br.com.bioscada.apps.biotracks.io.file.importer.ImportActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); importAll = intent.getBooleanExtra(EXTRA_IMPORT_ALL, false); trackFileFormat = intent.getParcelableExtra(EXTRA_TRACK_FILE_FORMAT); if (trackFileFormat == null) { trackFileFormat = TrackFileFormat.GPX; }// ww w . jav a 2 s .co m if (!FileUtils.isExternalStorageAvailable()) { Toast.makeText(this, R.string.external_storage_not_available, Toast.LENGTH_LONG).show(); finish(); return; } String directoryPath; if (importAll) { directoryDisplayName = FileUtils.getPathDisplayName(trackFileFormat.getExtension()); directoryPath = FileUtils.getPath(trackFileFormat.getExtension()); if (!FileUtils.isDirectory(new File(directoryPath))) { Toast.makeText(this, getString(R.string.import_no_directory, directoryDisplayName), Toast.LENGTH_LONG).show(); finish(); return; } } else { String action = intent.getAction(); if (!(Intent.ACTION_ATTACH_DATA.equals(action) || Intent.ACTION_VIEW.equals(action))) { Log.d(TAG, "Invalid action: " + intent); finish(); return; } Uri data = intent.getData(); if (!UriUtils.isFileUri(data)) { Log.d(TAG, "Invalid data: " + intent); finish(); return; } directoryDisplayName = data.getPath(); directoryPath = data.getPath(); } Object retained = getLastNonConfigurationInstance(); if (retained instanceof ImportAsyncTask) { importAsyncTask = (ImportAsyncTask) retained; importAsyncTask.setActivity(this); } else { importAsyncTask = new ImportAsyncTask(this, importAll, trackFileFormat, directoryPath); importAsyncTask.execute(); } }
From source file:com.reelyactive.blesdk.support.ble.ScanWakefulBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Logger.logDebug("Alarm triggered"); // This is the Intent to deliver to our scan service. Intent intentService = new Intent(context, ScanWakefulService.class).putExtra( ScanWakefulService.EXTRA_USE_LOLLIPOP_API, intent.getBooleanExtra(ScanWakefulService.EXTRA_USE_LOLLIPOP_API, true)); // Start the scan service, keeping the device awake while it is launching. This method will // explicitly grab a wakelock until the service tells the broadcast receiver to release it. startWakefulService(context, intentService); }
From source file:com.easytarget.micopi.BatchService.java
@Override protected void onHandleIntent(Intent intent) { startForeground(SERVICE_NOTIFICATION_ID, createNotification("", 10, 0)); final boolean doOverwrite = intent.getBooleanExtra(Constants.EXTRA_DO_OVERWRITE, false); final int screenWidthInPixels = intent.getIntExtra(Constants.EXTRA_IMAGE_SIZE, 1080); Log.d(LOG_TAG, "onHandleIntent: " + doOverwrite + ", " + screenWidthInPixels); mInsertErrors = new ArrayList<>(); mUpdateErrors = new ArrayList<>(); processContacts(doOverwrite, screenWidthInPixels); // if (mUpdateErrors.size() > 0 || mInsertErrors.size() > 0) createNotificationForError(); // LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("CONTACTS_UPDATED")); getContentResolver().notifyChange(ContactsContract.Data.CONTENT_URI, null); Intent progressBroadcast = new Intent(Constants.ACTION_FINISHED_GENERATE); sendBroadcast(progressBroadcast);/*from w w w . java 2 s. c om*/ stopForeground(true); }
From source file:com.ronnyml.sweetplayer.fragments.CommonFragment.java
private void getCommonData() { Intent intent = mActivity.getIntent(); if (intent != null) { String url = ""; if (intent.getBooleanExtra(Constants.IS_PLAYLIST, false)) { url = Constants.PLAYLIST_DETAIL_URL; } else if (intent.getBooleanExtra(Constants.IS_ARTIST, false)) { url = Constants.ARTISTS_DETAIL_URL; } else if (intent.getBooleanExtra(Constants.IS_GENRE, false)) { url = Constants.GENRE_DETAIL_URL; }/*from w w w . j a v a 2s.c om*/ String image = intent.getStringExtra(Constants.IMAGE); mImageView.setImageUrl(image, mImageLoader); String id = intent.getStringExtra(Constants.ID); getRequest(url + id); } }
From source file:autobahn.demo.com.autobahndemo.EchoClientActivity.java
@Override protected void onResume() { super.onResume(); mReceiver = new BroadcastReceiver() { @Override/*from w ww . j av a2 s . c om*/ public void onReceive(Context context, Intent intent) { boolean isConnectionLost = intent.getBooleanExtra("IsConnectionLost", false); boolean isConnectionOpen = intent.getBooleanExtra("IsConnectionOpen", false); boolean isMessageReceived = intent.getBooleanExtra("IsMessageReceived", false); if (isConnectionOpen) { mStatusline.setText("Status: Connected to " + ApplicationController.WS_URI); savePrefs(); mSendMessage.setEnabled(true); mMessage.setEnabled(true); mConnection.sendPingMessage(PING.getBytes()); } if (isConnectionLost) { String reason = intent.getStringExtra("Reason"); int code = intent.getIntExtra("CODE", 0); alert("Connection lost. " + reason); mStatusline.setText("Status: " + getTime() + " " + code + " " + reason); setButtonConnect(); } if (isMessageReceived) { String message = intent.getStringExtra("message"); Log.d(TAG, message); mTvEchoMessage.setText(message); messages.add(getTime() + " " + message); String[] messsagesArray = new String[messages.size()]; messsagesArray = messages.toArray(messsagesArray); ArrayAdapter<String> adapter = new ArrayAdapter<String>(EchoClientActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, messsagesArray); // ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_2, messages); mListView.setAdapter(adapter); } } }; IntentFilter intentFilter = new IntentFilter("MESSAGE"); LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, intentFilter); }
From source file:com.mfcoding.locationBP.receivers.LocationChangedReceiver.java
/** * When a new location is received, extract it from the Intent and use * it to start the Service used to update the list of nearby places. * //from ww w .ja v a 2 s. co m * This is the Active receiver, used to receive Location updates when * the Activity is visible. */ @Override public void onReceive(Context context, Intent intent) { String locationKey = LocationManager.KEY_LOCATION_CHANGED; String providerEnabledKey = LocationManager.KEY_PROVIDER_ENABLED; if (intent.hasExtra(providerEnabledKey)) { if (!intent.getBooleanExtra(providerEnabledKey, true)) { Intent providerDisabledIntent = new Intent( PlacesConstants.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED); context.sendBroadcast(providerDisabledIntent); } } if (intent.hasExtra(locationKey)) { Location location = (Location) intent.getExtras().get(locationKey); Log.d(TAG, "Actively Updating location lat:" + location.getLatitude() + " lng:" + location.getLongitude()); Intent updateServiceIntent = new Intent(context, PlacesConstants.SUPPORTS_ECLAIR ? EclairPlacesUpdateService.class : LocationUpdateService.class); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_LOCATION, location); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_RADIUS, PlacesConstants.DEFAULT_RADIUS); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_FORCEREFRESH, true); context.startService(updateServiceIntent); // Intent locUpdateIntent = new Intent(PlacesConstants.ACTIVE_LOCATION_UPDATE); // context.sendBroadcast(locUpdateIntent); } }
From source file:com.hplasplas.reminders.services.NotificationService.java
private void startActivityIfNeed(Intent handledIntent) { if (handledIntent.getBooleanExtra(NEED_ACTIVITY_START, false)) { Intent startSettingIntent = new Intent(this.getApplicationContext(), SettingsActivity.class); startSettingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startSettingIntent); }/*from w w w . j a v a 2 s . c om*/ }
From source file:com.hplasplas.reminders.services.NotificationService.java
@SuppressLint("ApplySharedPref") private boolean resetNotificationsCounter(Intent handledIntent) { if (handledIntent.getBooleanExtra(CURRENT_NOTIFICATION_READ, false)) { mNotificationPreferences.edit().putInt(UNREAD_NOTIFICATIONS_COUNTER, 0).commit(); return true; }//from w w w . j av a 2 s .c om return false; }
From source file:org.mitre.svmp.activities.AppRTCRefreshAppsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); preparingTextView.setText("Preparing your Apps"); Intent intent = getIntent(); this.fullRefresh = intent.getBooleanExtra("fullRefresh", false); }
From source file:com.jefftharris.passwdsafe.LauncherFileShortcuts.java
@Override protected void onCreate(Bundle savedInstanceState) { PasswdSafeApp.setupDialogTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher_file_shortcuts); FragmentManager fragMgr = getSupportFragmentManager(); FragmentTransaction txn = fragMgr.beginTransaction(); txn.replace(R.id.sync, new SyncProviderFragment()); txn.commit();/*from ww w . j a v a 2 s . c o m*/ if (savedInstanceState == null) { setFileChooseFrag(); } Intent intent = getIntent(); if (!Intent.ACTION_CREATE_SHORTCUT.equals(intent.getAction())) { finish(); return; } itsIsDefaultFile = intent.getBooleanExtra(EXTRA_IS_DEFAULT_FILE, false); if (itsIsDefaultFile) { setTitle(R.string.default_file_to_open); } else { setTitle(R.string.shortcut_file); } }