List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:foo.fruitfox.evend.LoginActivity.java
public void login(View view) { Intent intent = new Intent(this, WelcomeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);//www . ja v a 2s . c o m finish(); }
From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationService.java
/** * Adds an onclick handler to the notification *///from w w w . ja v a 2 s . com protected NotificationCompat.Builder setClickEvent(NotificationCompat.Builder builder) { int requestCode = new Random().nextInt(); Context context = getApplicationContext(); String packageName = context.getPackageName(); Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); launchIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, requestCode, launchIntent, PendingIntent.FLAG_CANCEL_CURRENT); return builder.setContentIntent(contentIntent); }
From source file:codepath.watsiapp.activities.BaseFragmentActivity.java
private void logout() { prefs.clearAll();//from w w w .j a v a 2 s .co m ParseUser.logOut(); // FLAG_ACTIVITY_CLEAR_TASK only works on API 11, so if the user // logs out on older devices, we'll just exit. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Intent intent = new Intent(BaseFragmentActivity.this, WatsiMainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { finish(); } }
From source file:com.insthub.O2OMobile.Activity.ReceiveOrderDialogActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.dialog_layout); show_message = getIntent().getStringExtra(CUSTOM_CONTENT); dialog_message = (TextView) findViewById(R.id.dialog_message); positive = (TextView) findViewById(R.id.yes); negative = (TextView) findViewById(R.id.no); JSONObject jsonObject = null;//from ww w . j a v a2s . com try { jsonObject = new JSONObject(show_message); final PUSH_MESSAGE message1 = new PUSH_MESSAGE(); message1.fromJson(jsonObject); dialog_message.setText(message1.content + getString(R.string.look_up_or_not)); positive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (message1.type == ENUM_MESSAGE_TYPE.ORDER.value()) { Intent it = new Intent(ReceiveOrderDialogActivity.this, D1_OrderActivity.class); it.putExtra(D1_OrderActivity.ORDER_ID, message1.order_id); it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ReceiveOrderDialogActivity.this.startActivity(it); (ReceiveOrderDialogActivity.this).overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out); } finish(); } }); negative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); } }); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.krayzk9s.imgurholo.services.DownloadService.java
@Override protected void onHandleIntent(Intent intent) { final NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); ids = intent.getParcelableArrayListExtra("ids"); albumName = "/"; downloaded = 0;// ww w. j ava 2 s. com if (ids.size() > 0) { albumName += intent.getStringExtra("albumName") + "/"; File myDirectory = new File( android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), albumName); if (!myDirectory.exists()) { myDirectory.mkdirs(); } } for (int i = 0; i < ids.size(); i++) { try { final String type = ids.get(i).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TYPE) .split("/")[1]; final String id = ids.get(i).getJSONObject().getString("id"); final String link = ids.get(i).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK); Log.d("data", ids.get(i).getJSONObject().toString()); Log.d(ImgurHoloActivity.IMAGE_DATA_TYPE, ids.get(0).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TYPE).split("/")[1]); Log.d("id", ids.get(i).getJSONObject().getString("id")); Log.d(ImgurHoloActivity.IMAGE_DATA_LINK, ids.get(0).getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK)); final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); notificationBuilder.setContentTitle(getString(R.string.picture_download)) .setContentText(getString(R.string.download_in_progress)) .setSmallIcon(R.drawable.icon_desaturated); Ion.with(getApplicationContext(), link).progress(new ProgressCallback() { @Override public void onProgress(int i, int i2) { notificationBuilder.setProgress(i2, i, false); } }).write(new File( android.os.Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + albumName + id + "." + type)) .setCallback(new FutureCallback<File>() { @Override public void onCompleted(Exception e, File file) { if (file == null) return; downloaded += 1; if (downloaded == ids.size()) { NotificationCompat.Builder notificationComplete = new NotificationCompat.Builder( getApplicationContext()); if (ids.size() == 1) { Intent viewImageIntent = new Intent(Intent.ACTION_VIEW); viewImageIntent.setDataAndType(Uri.fromFile(file), "image/*"); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); PendingIntent viewImagePendingIntent = PendingIntent.getActivity( getApplicationContext(), (int) System.currentTimeMillis(), viewImageIntent, 0); PendingIntent sharePendingIntent = PendingIntent.getActivity( getApplicationContext(), (int) System.currentTimeMillis(), shareIntent, 0); notificationComplete.setContentTitle(getString(R.string.download_complete)) .setSmallIcon(R.drawable.icon_desaturated) .setContentText(String.format(getString(R.string.download_progress), downloaded)) .setContentIntent(viewImagePendingIntent) .addAction(R.drawable.dark_social_share, getString(R.string.share), sharePendingIntent); } else { Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType( Uri.fromFile(new File( android.os.Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES) + albumName)), "image/*"); PendingIntent viewImagePendingIntent = PendingIntent.getActivity( getApplicationContext(), (int) System.currentTimeMillis(), i, 0); notificationComplete.setContentTitle(getString(R.string.download_complete)) .setSmallIcon(R.drawable.icon_desaturated).setContentText(String .format(getString(R.string.download_progress), downloaded)) .setContentIntent(viewImagePendingIntent); } notificationManager.cancel(0); notificationManager.cancel(1); notificationManager.notify(1, notificationComplete.build()); } MediaScannerConnection.scanFile(getApplicationContext(), new String[] { android.os.Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES) + albumName + id + "." + type }, null, new MediaScannerConnection.OnScanCompletedListener() { @Override public void onScanCompleted(final String path, final Uri uri) { Log.i("Scanning", String.format("Scanned path %s -> URI = %s", path, uri.toString())); } }); } }); notificationManager.notify(0, notificationBuilder.build()); } catch (JSONException e) { Log.e("Error!", e.toString()); } } }
From source file:org.wso2.emm.agent.api.ApplicationManager.java
/** * Removes an application from the device. * @param packageName - Application package name should be passed in as a String. *//*from w w w . j a v a 2 s . co m*/ public void uninstallApplication(String packageName) { if (packageName != null && !packageName.contains(resources.getString(R.string.application_package_prefix))) { packageName = resources.getString(R.string.application_package_prefix) + packageName; } Uri packageURI = Uri.parse(packageName); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(uninstallIntent); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
private void startViewer(Context context, Uri contentUri) { Log.d(TAG, "Launching viewer for " + contentUri); Intent i = new Intent(Intent.ACTION_VIEW); if (!(context instanceof Activity)) { i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }/*from ww w .j a v a 2 s .com*/ i.setDataAndType(contentUri, "video/*"); context.startActivity(i); }
From source file:com.kasoft.pushnot.GcmIntentService.java
private void sendNotification(String msg, String title, String form) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent appMainIntent = new Intent(getApplicationContext(), MainActivity.class); appMainIntent.putExtra("title", title); appMainIntent.putExtra("form", form); //appMainIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); appMainIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, appMainIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle().bigText(form)).setContentText(form); mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { try {// w w w . j a v a2 s .c o m JSONObject s = new JSONObject(savedInstanceState.getString("service")); setService(s); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } View v = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_report, container, false); mLocationView = (EditText) v.findViewById(R.id.address_string); // Register onClick handlers for all the clickables in the layout v.findViewById(R.id.mapChooserButton).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getActivity(), ChooseLocationActivity.class); startActivityForResult(i, CHOOSE_LOCATION_REQUEST); } }); v.findViewById(R.id.button_cancel).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); v.findViewById(R.id.button_submit).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { submit(v); } }); return v; }
From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java
/** * http://stackoverflow.com/questions/6547969/android-refresh-current-activity *//*from w w w .j a v a2 s .c om*/ public void restartActivity() { Intent intent = new Intent(activity, activity.getClass()); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.finish(); activity.startActivity(intent); }