List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:com.hx.template.ui.RegisterActivity.java
@OnClick({ R.id.getvcode, R.id.register, R.id.to_login }) public void onClick(View view) { switch (view.getId()) { case R.id.getvcode: if (checkPhone()) { if (FastClickUtils.isTimeToProcess(R.id.getvcode)) { getVerificationCode(username.getText().toString().trim()); }//from w ww. j a va2s .com } break; case R.id.register: if (checkInput()) { if (FastClickUtils.isTimeToProcess(R.id.register)) { register(username.getText().toString().trim(), password.getText().toString().trim(), DeviceUtils.getDeviceId(RegisterActivity.this), vcode.getText().toString().trim()); } } break; case R.id.to_login: if (FastClickUtils.isTimeToProcess(R.id.to_login)) { Intent intent = new Intent(RegisterActivity.this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } break; } }
From source file:com.example.administrator.myapplication2._5_Group._5_Group.LeftFragment.java
public void outGroup() { AsyncHttpClient client1 = new AsyncHttpClient(); client1.get("http://14.63.219.140:8080/han5/webresources/han5.grouping/deleteGrouping/" + id, new JsonHttpResponseHandler() { @Override/*from w w w. j a va2 s .c o m*/ public void onStart() { Log.i("boogil1", "outGroup receive json data start! "); } @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { Log.i("boogil1", "outGroup success! "); } @Override public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { Log.i("boogil1", "outGroup fail!"); } }); AsyncHttpClient client2 = new AsyncHttpClient(); client2.get("http://14.63.219.140:8080/han5/webresources/han5.nowgps/deleteNowgps/" + id, new JsonHttpResponseHandler() { @Override public void onStart() { Log.i("boogil1", "outGroup2 receive json data start! "); } @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { Log.i("boogil1", "outGroup2 success! "); } @Override public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { Log.i("boogil1", "outGroup2 fail!"); } }); //Set Class to Top of App and no history Intent launchNextActivity; launchNextActivity = new Intent(getActivity(), Main.class); launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(launchNextActivity); }
From source file:edu.mines.letschat.GcmIntentService.java
protected PendingIntent getDeleteIntent() { Intent resultBroadCastIntent = new Intent(); resultBroadCastIntent.setAction("deletion"); resultBroadCastIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); resultBroadCastIntent.addCategory(Intent.CATEGORY_DEFAULT); sendBroadcast(resultBroadCastIntent); return PendingIntent.getBroadcast(getBaseContext(), 0, resultBroadCastIntent, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:com.appteam.nimbus.activity.homeActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_logout) { personalData.SaveData(false);/* www.j av a 2 s . c o m*/ Intent launch_logout = new Intent(homeActivity.this, Login.class); launch_logout.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launch_logout.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); launch_logout.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(launch_logout); finish(); return true; } else if (id == R.id.action_leaderboard) { startActivity(new Intent(homeActivity.this, Leaderboard.class)); return true; } else if (id == R.id.action_important_contact) { CharSequence name[] = { "Ankush Sharma\n(Discipline Secretary)", "Rishabh Kumar\n(Discipline Joint Secretary)", "Kumud Jindal\n(Discipline Joint Secretary)", }; final CharSequence number[] = { "9736688292", "8627090570", "9882263949" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(android.R.drawable.ic_menu_call); builder.setTitle("Emergency Contact"); builder.setItems(name, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:+91" + number[i])); startActivity(intent); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } return super.onOptionsItemSelected(item); }
From source file:com.codebutler.farebot.activities.MainActivity.java
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.activity_main); ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); mDataCache = new HashMap<String, TransitIdentity>(); registerForContextMenu(getListView()); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); Intent intent = new Intent(this, ReadingTagActivity.class); intent.addFlags( Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY); mPendingIntent = PendingIntent.getActivity(this, 0, intent, 0); mTechLists = new String[][] { new String[] { IsoDep.class.getName() }, new String[] { MifareClassic.class.getName() }, new String[] { MifareUltralight.class.getName() }, new String[] { NfcF.class.getName() } }; setListAdapter(new CardsAdapter()); getLoaderManager().initLoader(0, null, this); }
From source file:jahirfiquitiva.iconshowcase.services.NotificationsService.java
@SuppressWarnings("ResourceAsColor") private void pushNotification(String content, int type, int ID) { Preferences mPrefs = new Preferences(this); String appName = Utils.getStringFromResources(this, R.string.app_name); String title = appName, notifContent = null; switch (type) { case 1://from w w w. ja v a 2s . c o m title = getResources().getString(R.string.new_walls_notif_title, appName); notifContent = getResources().getString(R.string.new_walls_notif_content, content); break; case 2: title = appName + " " + getResources().getString(R.string.news).toLowerCase(); notifContent = content; break; } // Send Notification NotificationManager notifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this); notifBuilder.setAutoCancel(true); notifBuilder.setContentTitle(title); if (notifContent != null) { notifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(notifContent)); notifBuilder.setContentText(notifContent); } notifBuilder.setTicker(title); Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); notifBuilder.setSound(ringtoneUri); if (mPrefs.getNotifsVibrationEnabled()) { notifBuilder.setVibrate(new long[] { 500, 500 }); } else { notifBuilder.setVibrate(null); } int ledColor = ThemeUtils.darkTheme ? ContextCompat.getColor(this, R.color.dark_theme_accent) : ContextCompat.getColor(this, R.color.light_theme_accent); notifBuilder.setColor(ledColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notifBuilder.setPriority(Notification.PRIORITY_HIGH); } Class appLauncherActivity = getLauncherClass(getApplicationContext()); if (appLauncherActivity != null) { Intent appIntent = new Intent(this, appLauncherActivity); appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); appIntent.putExtra("notifType", type); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(appLauncherActivity); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(appIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notifBuilder.setContentIntent(resultPendingIntent); } notifBuilder.setOngoing(false); notifBuilder.setSmallIcon(R.drawable.ic_notifications); Notification notif = notifBuilder.build(); if (mPrefs.getNotifsLedEnabled()) { notif.ledARGB = ledColor; } notifManager.notify(ID, notif); }
From source file:github.daneren2005.dsub.util.Util.java
public static void showPlayingNotification(final Context context, final DownloadServiceImpl downloadService, Handler handler, MusicDirectory.Entry song) { // Set the icon, scrolling text and timestamp final Notification notification = new Notification(R.drawable.stat_notify_playing, song.getTitle(), System.currentTimeMillis()); notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; boolean playing = downloadService.getPlayerState() == PlayerState.STARTED; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded); setupViews(expandedContentView, context, song, playing); notification.bigContentView = expandedContentView; }//from w w w . j av a 2 s. c o m RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification); setupViews(smallContentView, context, song, playing); notification.contentView = smallContentView; Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); notification.contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); handler.post(new Runnable() { @Override public void run() { downloadService.startForeground(Constants.NOTIFICATION_ID_PLAYING, notification); } }); // Update widget DSubWidgetProvider.notifyInstances(context, downloadService, true); }
From source file:com.xargsgrep.portknocker.activity.EditHostActivity.java
private void returnToHostListActivity(Boolean saveResult) { Intent hostListIntent = new Intent(this, HostListActivity.class); hostListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (saveResult != null) hostListIntent.putExtra(KEY_SAVE_HOST_RESULT, saveResult); startActivity(hostListIntent);//from w w w. j ava2 s .c o m }
From source file:com.onesignal.OneSignal.java
private static boolean openURLFromNotification(Context context, JSONArray dataArray) { int jsonArraySize = dataArray.length(); boolean urlOpened = false; for (int i = 0; i < jsonArraySize; i++) { try {//from w ww. j a v a2s.c o m JSONObject data = dataArray.getJSONObject(i); if (!data.has("custom")) continue; JSONObject customJSON = new JSONObject(data.getString("custom")); if (customJSON.has("u")) { String url = customJSON.getString("u"); if (!url.contains("://")) url = "http://" + url; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); urlOpened = true; } } catch (Throwable t) { Log(LOG_LEVEL.ERROR, "Error parsing JSON item " + i + "/" + jsonArraySize + " for launching a web URL.", t); } } return urlOpened; }
From source file:com.cssweb.android.common.FairyUI.java
/** * ??\// w ww . ja va 2s . co m * * @param paramInt * @param paramContext * @return */ public static Intent genIsLoginIntent(int paramInt, int paramInt2, Context paramContext) { Intent localIntent = new Intent(); if (genIsActiveIntent(paramInt, paramInt2, paramContext)) { if (!TradeUtil.checkUserLogin()) {// ? localIntent.putExtra("menu_id", paramInt); localIntent.setClass(paramContext, LoginActivity.class); } else { localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); String orgid = TradeUser.getInstance().getOrgid(); switch (paramInt2) { case Global.NJZQ_JLP_JYYH: localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); localIntent.putExtra("menu_id", paramInt2); if (1 == TradeUser.getInstance().getLoginType()) { localIntent = null; } else { localIntent.setClass(paramContext, LoginActivity.class); } break; case Global.NJZQ_WTJY: localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); localIntent.putExtra("menu_id", paramInt2); if (orgid == null || "".equals(orgid)) { localIntent.setClass(paramContext, LoginActivity.class); } else { localIntent.setClass(paramContext, JlpActivity.class); } break; case Global.NJZQ_WTJY_TWO: localIntent.putExtra("menu_id", Global.NJZQ_WTJY_GP_THREE); localIntent.setClass(paramContext, FundActivity.class); break; case Global.QUOTE_USERSTK: localIntent.putExtra("requestType", 1); localIntent.setClass(paramContext, PersonalStock.class); break; case Global.QUOTE_WARNING: case Global.NJZQ_HQBJ_HQYJ: if (TradeUser.getInstance().getLoginType() == 3) { localIntent.putExtra("menu_id", paramInt); localIntent.setClass(paramContext, LoginActivity.class); } else localIntent.setClass(paramContext, QuoteWarning.class); break; case Global.NJZQ_ZXHD_EGHT: localIntent.putExtra("menu_id", Global.NJZQ_ZXHD_EGHT); localIntent.setClass(paramContext, VistualTrade.class); break; case Global.QUOTE_PAIMING: localIntent.putExtra("requestType", 0); localIntent.setClass(paramContext, PaiMing.class); break; case Global.QUOTE_DAPAN: localIntent.putExtra("requestType", 2); localIntent.setClass(paramContext, DaPan.class); break; case Global.NJZQ_HQBJ_QQSC_WHSC: localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_QQSC_WHSC); localIntent.setClass(paramContext, GlobalMarket.class); break; case Global.QUOTE_FENLEI: localIntent.putExtra("requestType", 2); localIntent.setClass(paramContext, FenLei.class); break; case Global.QUOTE_STOCK: localIntent.putExtra("type", 0); localIntent.setClass(paramContext, StockTypeFund.class); break; case Global.QUOTE_BOND: localIntent.putExtra("type", 1); localIntent.setClass(paramContext, StockTypeFund.class); break; case Global.QUOTE_MONETARY: localIntent.putExtra("type", 2); localIntent.setClass(paramContext, StockTypeFund.class); break; case Global.QUOTE_MIX: localIntent.putExtra("type", 3); localIntent.setClass(paramContext, StockTypeFund.class); break; case Global.SUN_PRIVATE: localIntent.putExtra("type", 4); localIntent.setClass(paramContext, SunPrivate.class); break; case Global.HK_MAINBOARD: // ? Bundle bundle = new Bundle(); bundle.putInt("stocktype", 101); bundle.putInt("flag", 1); localIntent.putExtras(bundle); localIntent.setClass(paramContext, HKMainboard.class); break; case Global.HK_CYB: // ? Bundle bundle2 = new Bundle(); bundle2.putInt("stocktype", 102); bundle2.putInt("flag", 2); localIntent.putExtras(bundle2); localIntent.setClass(paramContext, HKMainboard.class); break; case Global.ZJS:// localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); localIntent.setClass(paramContext, ZJS.class); Bundle extras = new Bundle(); extras.putString("market", "cffex"); extras.putString("exchange", "cf"); extras.putString("title", ""); localIntent.putExtras(extras); break; case Global.SDZ:// ,, localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); localIntent.setClass(paramContext, QHSCBaseActivity.class); break; case Global.QUOTE_HSZS: localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); localIntent.setClass(paramContext, HSZS.class); break; case Global.QUOTE_KLINE: localIntent.setClass(paramContext, KLineActivity.class); break; case Global.QUOTE_FENSHI: localIntent.putExtra("exchange", CssSystem.exchange); localIntent.putExtra("stockcode", CssSystem.stockcode); localIntent.putExtra("stockname", CssSystem.stockname); localIntent.setClass(paramContext, TrendActivity.class); break; case Global.NJZQ_ZXHD_KHJL: localIntent.putExtra("pos", Global.NJZQ_ZXHD_KHJL); localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); localIntent.setClass(paramContext, WebViewDisplay.class); break; case Global.NJZQ_ZXHD_TZGW: if (TradeUser.getInstance().getLoginType() == 3) { localIntent.putExtra("menu_id", paramInt); localIntent.setClass(paramContext, LoginActivity.class); } else { localIntent.putExtra("pos", Global.NJZQ_ZXHD_TZGW); localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); localIntent.setClass(paramContext, WebViewDisplay.class); } break; } } } else { localIntent.putExtra("menu_id", paramInt); if (paramInt == Global.NJZQ_WTJY) { localIntent.putExtra("isChangeBtn", true); } localIntent.setClass(paramContext, SMSJHActivity.class); } return localIntent; }