List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:com.anjalimacwan.fragment.NoteViewFragment.java
public void onDeleteDialogPositiveClick() { // User touched the dialog's positive button deleteNote(filename);//from ww w. j ava 2s .c om showToast(R.string.note_deleted); if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) { // Send broadcast to NoteListFragment to refresh list of notes Intent listNotesIntent = new Intent(); listNotesIntent.setAction("com.anjalimacwan.LIST_NOTES"); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(listNotesIntent); } // Add NoteListFragment or WelcomeFragment Fragment fragment; if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) fragment = new NoteListFragment(); else fragment = new WelcomeFragment(); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); }
From source file:com.farmerbb.notepad.fragment.NoteViewFragment.java
public void onDeleteDialogPositiveClick() { // User touched the dialog's positive button deleteNote(filename);//from ww w . j av a 2 s.co m showToast(R.string.note_deleted); if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large")) { // Send broadcast to NoteListFragment to refresh list of notes Intent listNotesIntent = new Intent(); listNotesIntent.setAction("com.farmerbb.notepad.LIST_NOTES"); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(listNotesIntent); } // Add NoteListFragment or WelcomeFragment Fragment fragment; if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) fragment = new NoteListFragment(); else fragment = new WelcomeFragment(); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); }
From source file:com.notalenthack.blaster.CommandActivity.java
private void cancelStatusUpdate() { // Setup expiration if we never get a message from the service AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(); intent.setAction(Constants.ACTION_REFRESH_STATUS); PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pi);/*from w w w . ja v a 2 s. c o m*/ }
From source file:com.amaze.filemanager.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle b = new Bundle(); b.putInt("id", startId); epath = PreferenceManager.getDefaultSharedPreferences(this).getString("extractpath", ""); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String file = intent.getStringExtra("zip"); eentries = intent.getBooleanExtra("entries1", false); if (eentries) { entries = intent.getStringArrayListExtra("entries"); }//from ww w.ja va2 s . c om b.putString("file", file); DataPackage intent1 = new DataPackage(); intent1.setName(file); intent1.setTotal(0); intent1.setDone(0); intent1.setId(startId); intent1.setP1(0); intent1.setCompleted(false); hash1.put(startId, intent1); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra("openprocesses", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder = new NotificationCompat.Builder(cd); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.extracting)) .setContentText(new File(file).getName()).setSmallIcon(R.drawable.ic_doc_compressed); hash.put(startId, true); new Doback().execute(b); return START_STICKY; }
From source file:com.notalenthack.blaster.CommandActivity.java
private void startStatusUpdate() { // Setup expiration if we never get a message from the service AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(); intent.setAction(Constants.ACTION_REFRESH_STATUS); PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); // Set repeating updating of status, will need to cancel if activity is gone Calendar cal = Calendar.getInstance(); am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), Constants.UPATE_STATUS_PERIOD * 1000, pi); }
From source file:de.stadtrallye.rallyesoft.model.pictures.PictureManager.java
/** * Get an intent to either take a picture with the camera app or select an app that can pick an existing picture *//* w w w . j a v a 2 s . c o m*/ public Intent startPictureTakeOrSelect(SourceHint sourceHint) { //Attention: Our RequestCode will not be used for the result, if a jpeg is picked, data.getType will contain image/jpeg, if the picture was just taken with the camera it will be null Intent pickIntent = new Intent(); pickIntent.setType("image/jpeg"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { pickIntent.setAction(Intent.ACTION_OPEN_DOCUMENT); pickIntent.addCategory(Intent.CATEGORY_OPENABLE); } else { pickIntent.setAction(Intent.ACTION_GET_CONTENT); } Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri fileUri = getPicturePlaceholderUri(PictureManager.MEDIA_TYPE_IMAGE, sourceHint); // reserve a filename to save the image takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name takePhotoIntent.putExtra("return-data", true); Intent chooserIntent = Intent.createChooser(pickIntent, context.getString(R.string.select_take_picture)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent }); return chooserIntent; }
From source file:com.t2.biofeedback.BioFeedbackService.java
private Intent getStatusBroadcastIntent(SerialBTDevice d, String messageType, String messageId, Double value) { Intent i = new Intent(); i.setAction(ACTION_STATUS_BROADCAST); if (d != null) { i.putExtra(EXTRA_ADDRESS, d.getAddress()); i.putExtra(EXTRA_NAME, d.getName()); }// ww w .j av a 2 s . c o m i.putExtra(EXTRA_MESSAGE_TYPE, messageType); i.putExtra(EXTRA_MESSAGE_ID, messageId); i.putExtra(EXTRA_MESSAGE_VALUE, value); i.putExtra(EXTRA_TIMESTAMP, System.currentTimeMillis()); return i; }
From source file:com.anjalimacwan.fragment.NoteViewFragment.java
public void dispatchKeyShortcutEvent(int keyCode) { switch (keyCode) { // CTRL+E: Edit case KeyEvent.KEYCODE_E: Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle);/*from w ww.j av a 2 s. com*/ getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); break; // CTRL+D: Delete case KeyEvent.KEYCODE_D: // Show delete dialog listener.showDeleteDialog(); break; // CTRL+H: Share case KeyEvent.KEYCODE_H: // Send a share intent Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, contentsOnLoad); shareIntent.setType("text/plain"); // Verify that the intent will resolve to an activity, and send if (shareIntent.resolveActivity(getActivity().getPackageManager()) != null) startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to))); break; } }
From source file:com.moki.touch.fragments.views.WebContent.java
private void endSession() { Intent homeIntent = new Intent(); homeIntent.setAction(PlaylistActivity.HOME_INTENT); context.sendBroadcast(homeIntent);//w w w . j a va2 s .c o m }
From source file:com.vyasware.vaani.MainActivity.java
private void doOpen(String[] sentence) { System.out.println("open"); for (String word : sentence) { switch (word) { //? ??? case "?": case "facebook": //open facebook Intent fbintent = new Intent(); fbintent.setAction(Intent.ACTION_VIEW); fbintent.setData(android.net.Uri.parse("http://www.facebook.com")); startActivity(fbintent);//from w w w.ja va2 s.com break; case "whatsapp": case "???": //todo run whatsapp break; case "camera": case "": case "": //open camera Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); try { PackageManager pm = getPackageManager(); final ResolveInfo mInfo = pm.resolveActivity(i, 0); Intent intent = new Intent(); intent.setComponent(new ComponentName(mInfo.activityInfo.packageName, mInfo.activityInfo.name)); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); } catch (Exception e) { Log.i("open", "Unable to launch camera: " + e); } break; case "browser": case "?": // open browser Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(android.net.Uri.parse("http://www.google.com")); startActivity(intent); break; case "youtube": case "???": //run youtube Intent ytintent = new Intent(); ytintent.setAction(Intent.ACTION_VIEW); ytintent.setData(android.net.Uri.parse("http://www.youtube.com")); startActivity(ytintent); break; } } }