List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:com.digitalarx.android.files.FileOperationsHelper.java
public void renameFile(OCFile file, String newFilename) { // RenameFile Intent service = new Intent(mFileActivity, OperationsService.class); service.setAction(OperationsService.ACTION_RENAME); service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath()); service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename); mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service); mFileActivity.showLoadingDialog();/*from www.j a v a 2 s. co m*/ }
From source file:com.digitalarx.android.files.FileOperationsHelper.java
public void removeFile(OCFile file, boolean onlyLocalCopy) { // RemoveFile Intent service = new Intent(mFileActivity, OperationsService.class); service.setAction(OperationsService.ACTION_REMOVE); service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath()); service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy); mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service); mFileActivity.showLoadingDialog();/*ww w. j av a 2 s . c o m*/ }
From source file:com.digitalarx.android.files.FileOperationsHelper.java
public void createFolder(String remotePath, boolean createFullPath) { // Create Folder Intent service = new Intent(mFileActivity, OperationsService.class); service.setAction(OperationsService.ACTION_CREATE_FOLDER); service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); service.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath); service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath); mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service); mFileActivity.showLoadingDialog();/*from w ww. ja va 2s . c o m*/ }
From source file:au.com.cybersearch2.classyfy.TitleSearchResultsActivityTest.java
@Test public void test_Intents() { // Launch activity with ACTION_SEARCH intent and then trigger new ACTION_VIEW intent // Launch activity Intent intent = getNewIntent(); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, SEARCH_TEXT); createWithIntent(intent);//from w ww . ja v a 2s . c o m // Verify onCreate() resulted in LoaderCallbacks object being created assertThat(titleSearchResultsActivity.loaderCallbacks).isNotNull(); // Verify LoaderManager restartLoader called with correct search term ArgumentCaptor<Bundle> arguments = ArgumentCaptor.forClass(Bundle.class); verify(loaderManager).restartLoader(eq(0), arguments.capture(), eq(titleSearchResultsActivity.loaderCallbacks)); assertThat(arguments.getValue().containsKey("QUERY_TEXT_KEY")); assertThat(arguments.getValue().get("QUERY_TEXT_KEY")).isEqualTo(SEARCH_TEXT); // Verify setOnItemClickListener called on view verify(listView).setOnItemClickListener(isA(OnItemClickListener.class)); // Verify Loader constructor arguments have correct details SuggestionCursorParameters params = new SuggestionCursorParameters(arguments.getValue(), ClassyFySearchEngine.LEX_CONTENT_URI, 50); assertThat(params.getUri()) .isEqualTo(Uri.parse("content://au.com.cybersearch2.classyfy.ClassyFyProvider/lex/" + SearchManager.SUGGEST_URI_PATH_QUERY)); assertThat(params.getProjection()).isNull(); assertThat(params.getSelection()).isEqualTo("word MATCH ?"); assertThat(params.getSelectionArgs()).isEqualTo(new String[] { SEARCH_TEXT }); assertThat(params.getSortOrder()).isNull(); // Verify Loader callbacks in sequence onCreateLoader, onLoadFinished and onLoaderReset CursorLoader cursorLoader = (CursorLoader) titleSearchResultsActivity.loaderCallbacks.onCreateLoader(0, arguments.getValue()); Cursor cursor = mock(Cursor.class); titleSearchResultsActivity.loaderCallbacks.onLoadFinished(cursorLoader, cursor); verify(simpleCursorAdapter).swapCursor(cursor); titleSearchResultsActivity.loaderCallbacks.onLoaderReset(cursorLoader); verify(simpleCursorAdapter).swapCursor(null); // Trigger new ACTION_VIEW intent and confirm MainActivity started with ACTION_VIEW intent intent = getNewIntent(); intent.setAction(Intent.ACTION_VIEW); Uri actionUri = Uri.withAppendedPath(ClassyFySearchEngine.CONTENT_URI, "44"); intent.setData(actionUri); titleSearchResultsActivity.onNewIntent(intent); ShadowActivity shadowActivity = Robolectric.shadowOf(titleSearchResultsActivity); Intent startedIntent = shadowActivity.getNextStartedActivity(); assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(startedIntent.getData()).isEqualTo(actionUri); ShadowIntent shadowIntent = Robolectric.shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName()) .isEqualTo("au.com.cybersearch2.classyfy.MainActivity"); }
From source file:alaindc.crowdroid.SensorsIntentService.java
public void stub_onSensorChanged(int typeSensor) { if (typeSensor < 0) return;/*w w w .j av a 2 s.c o m*/ float value, minf, maxf; switch (typeSensor) { case Sensor.TYPE_AMBIENT_TEMPERATURE: minf = -20; maxf = 42; break; case Sensor.TYPE_PRESSURE: // https://it.wikipedia.org/wiki/Pressione_atmosferica minf = 870; maxf = 1085; break; case Sensor.TYPE_RELATIVE_HUMIDITY: minf = 30; maxf = 100; break; default: minf = 0; maxf = 0; break; } value = random.nextFloat() * (maxf - minf) + minf; int index = Constants.getIndexAlarmForSensor(typeSensor); SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(Constants.PREF_SENSOR_ + typeSensor, Float.toString(value)); editor.commit(); // Update view Intent senseintent = new Intent(Constants.INTENT_UPDATE_SENSORS); senseintent.putExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA, "Sensor " + Constants.getNameOfSensor(typeSensor) + " value: " + Float.toString(value)); LocalBroadcastManager.getInstance(this).sendBroadcast(senseintent); // Set the alarm random alarmMgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Intent intentAlarm = new Intent(getApplicationContext(), SensorsIntentService.class); intentAlarm.setAction(Constants.INTENT_STUB_SENSOR_CHANGED + typeSensor); intentAlarm.putExtra(Constants.INTENT_STUB_SENSOR_CHANGED_TYPE, typeSensor); alarmIntent = PendingIntent.getService(getApplicationContext(), 0, intentAlarm, 0); // TODO Set timeout time from server indications int seconds = random.nextInt(50) + 10; // 10/60 sec alarmMgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + seconds * 1000, alarmIntent); }
From source file:net.eledge.android.europeana.gui.activity.HomeActivity.java
private void performSearch(String query) { final Intent intent = new Intent(this, SearchActivity.class); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, query); SearchProfile selected = (SearchProfile) mSpinnerProfiles.getSelectedItem(); if ((selected != null) && (selected.facets != null)) { intent.putExtra(SearchManager.USER_QUERY, selected.facets); }/* ww w . j a v a 2 s . co m*/ this.startActivity(intent); }
From source file:org.lumicall.android.sip.RegisterAccount.java
protected void doSIP5060Provisioning() { buttonOK.setEnabled(false);//from www . j a v a 2 s . c o m storeSettings(null); final Intent intent = new Intent(this, EnrolmentService.class); intent.setAction(EnrolmentService.ACTION_ENROL_SMS); //intent.setAction(RegistrationPhaseTwo.ACTION); startService(intent); //doValidationActivity(); // FIXME - hiding the SMS validation temporarily finish(); }
From source file:com.digitalarx.android.files.FileOperationsHelper.java
public void shareFileWithLinkToApp(OCFile file, Intent sendIntent) { if (file != null) { mFileActivity.showLoadingDialog(); Intent service = new Intent(mFileActivity, OperationsService.class); service.setAction(OperationsService.ACTION_CREATE_SHARE); service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath()); service.putExtra(OperationsService.EXTRA_SEND_INTENT, sendIntent); mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service); } else {/* ww w . j a va 2 s. c om*/ Log_OC.wtf(TAG, "Trying to open a NULL OCFile"); } }
From source file:com.parse.CN1ParsePushBroadcastReceiver.java
@Override protected void onPushReceive(Context context, Intent intent) { /*//w w w . j a v a 2 s.c o m Adapted from ParsePushBroadcastReceiver.onPushReceived(). Main changes: 1. Implemented callbacks to ParsePush with the push payload based on app state */ JSONObject pushData = null; try { pushData = new JSONObject(intent.getStringExtra(ParsePushBroadcastReceiver.KEY_PUSH_DATA)); } catch (JSONException e) { writeErrorLog("Unexpected JSONException when parsing received push data:\n" + e); } writeDebugLog("Push received: " + (pushData == null ? "<no payload>" : pushData.toString())); boolean handled = false; if (pushData != null && CN1AndroidApplication.isAppRunning()) { if (CN1AndroidApplication.isAppInForeground()) { writeDebugLog("App in foreground; will allow app to directly handle push message, if desired"); handled = ParsePush.handlePushReceivedForeground(pushData.toString()); } else if (CN1AndroidApplication.isAppInBackground()) { writeDebugLog("App in background; will allow app to directly handle push message, if desired"); handled = ParsePush.handlePushReceivedBackground(pushData.toString()); } } if (!handled) { // If the push data includes an action string, that broadcast intent is fired. String action = null; if (pushData != null) { action = pushData.optString("action", null); } if (action != null) { writeDebugLog("Firing broadcast for action " + action); Bundle extras = intent.getExtras(); Intent broadcastIntent = new Intent(); broadcastIntent.putExtras(extras); broadcastIntent.setAction(action); broadcastIntent.setPackage(context.getPackageName()); context.sendBroadcast(broadcastIntent); } Notification notification = getNotification(context, intent); if (notification != null) { writeDebugLog("Scheduling notification for push message since it was not handled by app"); ParseNotificationManager.getInstance().showNotification(context, notification); } else { // If, for any reason, creating the notification fails (typically because // the push is a 'hidden' push with no alert/title fields), // store it for later processing. if (pushData != null) { writeDebugLog("Requesting ParsePush to handle unprocessed (hidden?) push message"); ParsePush.handleUnprocessedPushReceived(pushData.toString()); } } } else { writeDebugLog("Push already handled by app so not scheduling any notification"); } }
From source file:com.phonegap.CameraLauncher.java
/** * Get image from photo library./*from www . j a v a 2 s .c o m*/ * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param srcType The album to get image from. * @param returnType Set the type of image to return. */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! public void getImage(int quality, int srcType, int returnType) { this.mQuality = quality; Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); this.ctx.startActivityForResult((Plugin) this, Intent.createChooser(intent, new String("Get Picture")), (srcType + 1) * 16 + returnType + 1); }