List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:com.anandroid.firebase.utils.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. */// ww w. j a va2 s . c o m private void sendNotification(String messageBody) { Intent intent; if (messageBody.indexOf("F") == 0) { intent = new Intent(this, Analytics.class); } else { intent = new Intent(this, MainActivity.class); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("FCM Message").setContentText(messageBody) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:org.roman.findme.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww . j a v a 2 s.c om */ private void sendNotification(String message) { Intent intent = new Intent(this, MessageActivity.class); intent.putExtra("message", message); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle("Message").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); if (sharedPreferences.getBoolean("display_message", true)) { displayMessage(message); } }
From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { try {/*from w w w . jav a 2 s. co 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.app.ntuc.notifs.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w w w. j a va 2 s . c o m */ private void sendNotification(String body, String title, Bundle bundle) { Intent intent = new Intent(this, MainActivity2_.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); bigText.bigText(bundle.toString()); bigText.setBigContentTitle(body); bigText.setSummaryText(title); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); notificationBuilder.setContentTitle(body).setContentText(title); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(6969, notificationBuilder.build()); }
From source file:com.cbtec.eliademy.EliademyLms.java
/** * Executes the request./*from ww w . jav a2 s .c o m*/ * * This method is called from the WebView thread. To do a non-trivial amount * of work, use: cordova.getThreadPool().execute(runnable); * * To run on the UI thread, use: * cordova.getActivity().runOnUiThread(runnable); * * @param action * The action to execute. * @param rawArgs * The exec() arguments in JSON form. * @param callbackContext * The callback context used when calling back into JavaScript. * @return Whether the action was valid. * @throws JSONException */ @Override public boolean execute(String action, JSONArray data, final CallbackContext callbackContext) throws JSONException { Log.i("HLMS", action); if ((action.compareTo("openfilesrv") == 0)) { try { Uri fileuri = Uri.parse(data.getString(0)); Intent intent = new Intent(Intent.ACTION_VIEW); String mimeextn = android.webkit.MimeTypeMap.getFileExtensionFromUrl(data.getString(0)); if (mimeextn.isEmpty()) { mimeextn = data.getString(0).substring(data.getString(0).indexOf(".") + 1); ; } String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeextn); Log.i("HLMS", fileuri + " " + mimetype); intent.setDataAndType(fileuri, mimetype); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); cordova.getActivity().getApplicationContext().startActivity(intent); callbackContext.success(); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return true; } else if ((action.compareTo("getfilesrv") == 0)) { this.mCallbackContext = callbackContext; cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*");// TODO: Restrict file types cordova.startActivityForResult(EliademyLms.this, intent, submitFileCode); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return; } }); } else if ((action.compareTo("initservice") == 0)) { if (!mIsBound) { this.mCallbackContext = callbackContext; JSONObject tmp = new JSONObject(data.getString(0)); String sname = tmp.getString("servicename"); if (sname.contains("eliademy")) { mServiceName = "com.cbtec.serviceeliademy"; } else { // From url determine version 2.2, 2.3, 2.4 and change mServiceName = "com.cbtec.service" + sname; } Log.i("HLMS", "Connecting to service: " + mServiceName); doBindService(); } else { callbackContext.success(); } return true; } else { final String aAction = action; final JSONArray aData = data; String mappedCmd = null; try { mappedCmd = mapExecCommand(aData.getString(0)); } catch (JSONException e) { Log.e("HLMS", "exception", e); } if (mappedCmd == null) { Log.i("HLMS", "LMS service call failed " + mappedCmd); callbackContext.error(0);// TODO : error enum return false; } final String execCmd = mappedCmd; cordova.getThreadPool().execute(new Runnable() { @Override @SuppressLint("NewApi") public void run() { Log.i("HLMS", "Runner execute " + aAction + aData.toString()); if (aAction.compareTo("lmsservice") == 0) { try { String retval = null; Log.i("HLMS", "Execute cmd: " + execCmd); if (execCmd.compareTo("initialize") == 0) { if (mIBinder.initializeService(aData.getString(1))) { String token = mIBinder.eliademyGetWebServiceToken(); callbackContext.success(token); return; } } else if (execCmd.compareTo("deinitialize") == 0) { if (mIBinder.deInitializeService(aData.getString(1))) { doUnbindService(); callbackContext.success(); return; } } else if (execCmd.compareTo("pushregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.registerPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("pushunregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.unregisterPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("servicetoken") == 0) { retval = mIBinder.eliademyGetWebServiceToken(); } else if (execCmd.compareTo("siteinfo") == 0) { retval = mIBinder.eliademyGetSiteInformation(aData.getString(1)); } else if (execCmd.compareTo("get_user_courses") == 0) { retval = mIBinder.eliademyGetUsersCourses(aData.getString(1)); } else if (execCmd.compareTo("get_user_forums") == 0) { retval = mIBinder.eliademyGetUserForums(aData.getString(1)); } else if (execCmd.compareTo("get_user_info") == 0) { retval = mIBinder.eliademyGetUserInformation(aData.getString(1)); } else if (execCmd.compareTo("exec_webservice") == 0) { Log.i("HLMS", "Execute webservice"); retval = mIBinder.eliademyExecWebService(aData.getString(0), aData.getString(1)); } else if (execCmd.compareTo("course_get_contents") == 0) { retval = mIBinder.eliademyGetCourseContents(aData.getString(1)); } else if (execCmd.compareTo("course_get_enrolled_users") == 0) { retval = mIBinder.eliademyGetEnrolledUsers(aData.getString(1)); } else { Log.i("HLMS", "LMS service failed " + execCmd); callbackContext.error(0);// TODO : error enum } if (!retval.isEmpty()) { Log.i("HLMS", "LMS service call success"); callbackContext.success(retval); } else { Log.i("HLMS", "LMS service call failed"); callbackContext.error(0);// TODO : error enum } } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(e.getMessage()); return; } } else { Log.i("LMS", "Unsupported action call !!"); callbackContext.error(0); return; } } }); } return true; }
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 ww w . j av a2 s. c o m } 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:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_explain_moshaver); Fabric.with(this, new Crashlytics()); alagestarmoshaver = (ImageView) findViewById(R.id.alagestarmoshaver); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { placeid = ""; } else {/*from w ww . j a v a 2s . c o m*/ placeid = extras.getString("placeid"); } } else { placeid = (String) savedInstanceState.getSerializable("placeid"); } ImageView imageView1 = (ImageView) findViewById(R.id.backButton); imageView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ExplainMoshaver.this, PageMoshaverin.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); } }); final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); ImageView imageView = (ImageView) findViewById(R.id.menuButton); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { drawer.openDrawer(Gravity.END); } }); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(true); nav_Menu.findItem(R.id.nav_login).setVisible(false); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(true); } else { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(false); nav_Menu.findItem(R.id.nav_login).setVisible(true); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(false); } userimg = (ImageView) findViewById(R.id.adviser_image); name_moshaver_textview = (TextView) findViewById(R.id.name_moshaver_textview); //taxassose_moshaver_textview =(TextView) findViewById(R.id.taxassose_moshaver_textview); code_moshaver_textview = (TextView) findViewById(R.id.code_moshaver_textview); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { adviseridm = "0"; } else { adviseridm = extras.getString("adviserid"); } } else { adviseridm = (String) savedInstanceState.getSerializable("adviserid"); } //Toast.makeText(getApplicationContext(), "+"+adviseridm+"+", Toast.LENGTH_LONG).show(); if (isOnline()) { //requestData(); postgetData(); //Log.i("Lieseesene",License); ImageView imageView2 = (ImageView) findViewById(R.id.adviser_about_img); imageView2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //requestDataa(); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { Intent intent3 = new Intent(ExplainMoshaver.this, PageRezerv.class); intent3.putExtra("adviseridm", adviseridm); intent3.putExtra("placeid", placeid); intent3.putExtra("namemoshaver", namemoshaver); startActivity(intent3); } else { Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_LONG).show(); } } }); // // final ImageView alagestarmarkaz = (ImageView)findViewById(R.id.alagestarmarkaz); alagestarmoshaver.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcpsdcpsdcpsdc"+alagestarmarkaz.getResources()); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { setAlage(); //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcp2sdcpsdcpsdc"+hanyayo); } else { Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_LONG).show(); } } }); ImageView adviser_reserve_img = (ImageView) findViewById(R.id.adviser_reserve_img); adviser_reserve_img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final LinearLayout darbareyehuseyin = (LinearLayout) findViewById(R.id.darbareyehuseyin); darbareyehuseyin.setVisibility(View.VISIBLE); TextView textTagsHusseyin = (TextView) findViewById(R.id.textTagsHusseyin); try { textTagsHusseyin.setText(Tagggggggs); ImageView closeafzundanejavab = (ImageView) findViewById(R.id.closeinvisibleimag); closeafzundanejavab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { darbareyehuseyin.setVisibility(View.GONE); } }); } catch (Exception e) { textTagsHusseyin.setText(""); } } }); } else { Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show(); } }
From source file:com.gh4a.BlogListActivity.java
@Override public boolean setMenuOptionItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: if (!isAuthorized()) { Intent intent = new Intent().setClass(this, Github4AndroidActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/*from www . j av a 2s .c om*/ finish(); } else { getApplicationContext().openUserInfoActivity(this, getAuthLogin(), null, Intent.FLAG_ACTIVITY_CLEAR_TOP); return true; } case R.id.pub_timeline: Intent intent = new Intent().setClass(this, TimelineActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); return true; case R.id.trend: intent = new Intent().setClass(this, TrendingActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); return true; default: return true; } }
From source file:com.androiddevbook.onyourbike.chapter11.activities.BaseActivity.java
private void gotoHome() { Log.d(CLASS_NAME, "gotoHome"); Intent timer = new Intent(this, TimerActivity.class); timer.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(timer);/*w ww .j a va 2s. co m*/ }
From source file:com.aniruddhc.acemusic.player.Dialogs.AlbumArtSourceDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mContext = getActivity().getApplicationContext(); dialog = this; sharedPreferences = mContext.getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); String[] albumArtSources = getActivity().getResources().getStringArray(R.array.album_art_sources); //Check which frequency is currently selected and set the appropriate flag. if (sharedPreferences.getInt("ALBUM_ART_SOURCE", 0) == 0) { userSelection = 0;//w ww. ja v a 2s . c o m } else if (sharedPreferences.getInt("ALBUM_ART_SOURCE", 0) == 1) { userSelection = 1; } else if (sharedPreferences.getInt("ALBUM_ART_SOURCE", 0) == 2) { userSelection = 2; } else if (sharedPreferences.getInt("ALBUM_ART_SOURCE", 0) == 3) { userSelection = 3; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.album_art_sources); builder.setSingleChoiceItems(albumArtSources, userSelection, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int which) { //Update the SharedPreferences entry based on the user's selection. if (which == 0) { //"Prefer embedded art" sharedPreferences.edit().putInt("ALBUM_ART_SOURCE", 0).commit(); } else if (which == 1) { //"Prefer folder art" sharedPreferences.edit().putInt("ALBUM_ART_SOURCE", 1).commit(); } else if (which == 2) { //"Use embedded art only" sharedPreferences.edit().putInt("ALBUM_ART_SOURCE", 2).commit(); } else if (which == 3) { //"User folder art only" sharedPreferences.edit().putInt("ALBUM_ART_SOURCE", 3).commit(); } //Rescan for album art. //Seting the "RESCAN_ALBUM_ART" flag to true will force MainActivity to rescan the folders. sharedPreferences.edit().putBoolean("RESCAN_ALBUM_ART", true).commit(); //Restart the app. final Intent i = getActivity().getBaseContext().getPackageManager() .getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); getActivity().finish(); startActivity(i); dialog.dismiss(); getActivity().finish(); Toast.makeText(mContext, R.string.changes_saved, Toast.LENGTH_LONG).show(); } }); return builder.create(); }