List of usage examples for android.content Intent FLAG_ACTIVITY_SINGLE_TOP
int FLAG_ACTIVITY_SINGLE_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_SINGLE_TOP.
Click Source Link
From source file:com.smc.tw.waltz.MainActivity.java
@Override public void onConnectWifi(int index) { if (DEBUG)/* ww w .j a va2s. c o m*/ Log.d(TAG, "onConnectWifi i:" + index); if (index < 0 || index >= MainApplication.getWaltzDeviceNumber()) return; try { Intent intent = new Intent(this, NetworkActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(NetworkActivity.WALTZ_INDEX, index); startActivityForResult(intent, RESULT_CONNECT_WIFI); } catch (ActivityNotFoundException e) { } }
From source file:com.smc.tw.waltz.MainActivity.java
@Override public void onConnectWifi(WaltzDevice device) { int index;/*from ww w. j ava 2 s .c om*/ if (device == null) return; index = MainApplication.getWaltzDeviceIndex(device); if (DEBUG) Log.d(TAG, "onConnectWifi i:" + index); try { Intent intent = new Intent(this, NetworkActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(NetworkActivity.WALTZ_INDEX, index); //startActivityForResult(intent, RESULT_CONNECT_WIFI); startActivity(intent); } catch (ActivityNotFoundException e) { } }
From source file:com.android.mms.transaction.MessagingNotification.java
private static final Intent getClickIntent(Context context, boolean isSms, long threadId) { Intent intent;//from w ww . j a v a 2 s .c o m if (!MessageUtils.isMailboxMode()) { intent = ComposeMessageActivity.createIntent(context, threadId); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(MessageUtils.EXTRA_KEY_NEW_MESSAGE_NEED_RELOAD, true); } else if (isSms) { intent = new Intent(context, MailBoxMessageContent.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else if (DownloadManager.getInstance().isAuto()) { intent = new Intent(context, MobilePaperShowActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else { // Else case: for MMS not downloaded. intent = new Intent(context, MailBoxMessageList.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(MessageUtils.MAIL_BOX_ID, MailBoxMessageList.TYPE_INBOX); } return intent; }
From source file:com.instiwork.RegistrationFacebookActivity.java
public void login_User(final String URL) { pDialogOut.show();// w w w. j a va 2 s .co m Logger.showMessage(TAG, "OutSide login_User" + URL); JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, URL, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Logger.showMessage(TAG, "Inside login_User" + URL); Logger.showMessage(TAG, response.toString()); Logger.showMessage(TAG, imgPath); pDialogOut.hide(); txt_terms_conditions.setClickable(true); findViewById(R.id.help_dob).setClickable(true); findViewById(R.id.help_license).setClickable(true); ll_license.setClickable(true); dateOfBirth.setClickable(true); findViewById(R.id.footer).setClickable(true); findViewById(R.id.loginBttn).setClickable(true); txt_terms_conditions.setEnabled(true); findViewById(R.id.help_dob).setEnabled(true); findViewById(R.id.help_license).setEnabled(true); ll_license.setEnabled(true); dateOfBirth.setEnabled(true); findViewById(R.id.footer).setEnabled(true); findViewById(R.id.loginBttn).setEnabled(true); try { InstiworkApplication.getInstance().setSelectedLicenseArray(null); if (response.getJSONObject("response").getString("status") .equalsIgnoreCase("Success")) { InstiworkApplication.getInstance() .setUSER_ID(response.getJSONObject("response").getString("id")); InstiworkApplication.getInstance() .setUSER_NAME(response.getJSONObject("response").getString("name")); InstiworkApplication.getInstance().setCOMPANY_NAME( response.getJSONObject("response").getString("companyname")); InstiworkApplication.getInstance() .setUSER_EMAIL(response.getJSONObject("response").getString("email")); InstiworkApplication.getInstance() .setMOBILE_NO(response.getJSONObject("response").getString("contact")); try { InstiworkApplication.getInstance().setJOB_SEARCH_RADIUS( response.getJSONObject("response").getString("distance")); InstiworkApplication.getInstance() .setUnit_user(response.getJSONObject("response").getString("unit")); } catch (Exception e) { try { InstiworkApplication.getInstance().setJOB_SEARCH_RADIUS( response.getJSONObject("response").getString("distance_user")); InstiworkApplication.getInstance().setUnit_user( response.getJSONObject("response").getString("unit_user")); } catch (Exception ex) { ex.printStackTrace(); } } try { InstiworkApplication.getInstance().setPush_status( response.getJSONObject("response").getString("push_status")); InstiworkApplication.getInstance().setEmail_status( response.getJSONObject("response").getString("email_status")); InstiworkApplication.getInstance().setText_status( response.getJSONObject("response").getString("text_status")); InstiworkApplication.getInstance().setCountryid( response.getJSONObject("response").getString("country_id")); InstiworkApplication.getInstance().setCurrency_id( response.getJSONObject("response").getString("currency_id")); InstiworkApplication.getInstance().setCountry_name( response.getJSONObject("response").getString("country_name")); InstiworkApplication.getInstance().setCountry_3_code( response.getJSONObject("response").getString("country_3_code")); InstiworkApplication.getInstance().setCountry_2_code( response.getJSONObject("response").getString("country_2_code")); InstiworkApplication.getInstance().setCurrency_code( response.getJSONObject("response").getString("currency_code")); InstiworkApplication.getInstance().setCurrency_name( response.getJSONObject("response").getString("currency_name")); InstiworkApplication.getInstance().setMember_since( response.getJSONObject("response").getString("member_since")); } catch (Exception e) { Logger.showMessage(TAG, "Extra Paremeter : " + e.toString()); } InstiworkApplication.getInstance() .setUSER_IMG(response.getJSONObject("response").getString("profileimage")); try { licenseLinkedList = new LinkedList<JSONObject>(); if (response.getJSONObject("response").getJSONArray("license").length() > 0) { for (int i = 0; i < response.getJSONObject("response") .getJSONArray("license").length(); i++) { licenseLinkedList.add(response.getJSONObject("response") .getJSONArray("license").getJSONObject(i)); } InstiworkApplication.getInstance().setLicenseArray(licenseLinkedList); } else { InstiworkApplication.getInstance().setLicenseArray(null); } } catch (Exception e) { InstiworkApplication.getInstance().setLicenseArray(null); Logger.showMessage(TAG, "license Exception" + e.toString()); } SharedPreferences.Editor edit = appSharedPref.edit(); edit.putString("USER_ID", response.getJSONObject("response").getString("id")); try { edit.putString("CURRENCY_ID", response.getJSONObject("response").getString("currency_id")); } catch (Exception e) { e.printStackTrace(); } edit.commit(); try { Map<String, Object> params = new HashMap<>(); params.put("action", "facebook_registration"); params.put("action_user_id", InstiworkApplication.getInstance().getUSER_ID()); params.put("action_user_name", InstiworkApplication.getInstance().getUSER_NAME()); params.put("action_device", "android"); AdWordsRemarketingReporter.reportWithConversionId(getApplicationContext(), getResources().getString(R.string.conversion_id), params); } catch (Exception e) { Logger.showMessage(TAG, "AdWords : " + e.toString()); } Toast.makeText(RegistrationFacebookActivity.this, "Registered successfully", Toast.LENGTH_SHORT).show(); Intent i = new Intent(getApplicationContext(), LandingActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(i); finish(); } else { pDialogOut.hide(); // Toast.makeText(RegistrationFacebookActivity.this, response.getJSONObject("response").getString("message"), Toast.LENGTH_SHORT).show(); // Snackbar.make(findViewById(android.R.id.content), response.getString("details"), Snackbar.LENGTH_LONG) // .setActionTextColor(Color.RED) // .show(); try { displayMessage(response.getString("details")); // Snackbar.make(findViewById(android.R.id.content), response.getString("details"), Snackbar.LENGTH_LONG) // .setActionTextColor(Color.RED) // .show(); } catch (Exception ee) { ee.printStackTrace(); try { displayMessage(response.getString("message")); } catch (Exception eee) { eee.printStackTrace(); } } } } catch (Exception e) { e.printStackTrace(); try { displayMessage(response.getString("details")); // Snackbar.make(findViewById(android.R.id.content), response.getString("details"), Snackbar.LENGTH_LONG) // .setActionTextColor(Color.RED) // .show(); } catch (Exception ee) { ee.printStackTrace(); try { displayMessage(response.getString("message")); } catch (Exception eee) { eee.printStackTrace(); } } pDialogOut.hide(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Logger.showMessage(TAG, "Vollllllllll Error: " + error.getMessage()); pDialogOut.hide(); txt_terms_conditions.setClickable(true); findViewById(R.id.help_dob).setClickable(true); findViewById(R.id.help_license).setClickable(true); ll_license.setClickable(true); dateOfBirth.setClickable(true); findViewById(R.id.footer).setClickable(true); findViewById(R.id.loginBttn).setClickable(true); txt_terms_conditions.setEnabled(true); findViewById(R.id.help_dob).setEnabled(true); findViewById(R.id.help_license).setEnabled(true); ll_license.setEnabled(true); dateOfBirth.setEnabled(true); findViewById(R.id.footer).setEnabled(true); findViewById(R.id.loginBttn).setEnabled(true); if (error instanceof NoConnectionError) { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder( RegistrationFacebookActivity.this); builder.setTitle("Instiwork"); builder.setMessage("You do not have internet connection!"); builder.setPositiveButton("retry", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); pDialogOut.show(); txt_terms_conditions.setClickable(false); findViewById(R.id.help_dob).setClickable(false); findViewById(R.id.help_license).setClickable(false); ll_license.setClickable(false); dateOfBirth.setClickable(false); findViewById(R.id.footer).setClickable(false); findViewById(R.id.loginBttn).setClickable(false); txt_terms_conditions.setEnabled(false); findViewById(R.id.help_dob).setEnabled(false); findViewById(R.id.help_license).setEnabled(false); ll_license.setEnabled(false); dateOfBirth.setEnabled(false); findViewById(R.id.footer).setEnabled(false); findViewById(R.id.loginBttn).setEnabled(false); login_User(URL); } }); builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.setCancelable(false); builder.show(); } else { try { String json = null; NetworkResponse response = error.networkResponse; if (response != null && response.data != null) { json = new String(response.data); json = trimMessage(json, "message"); if (json != null) // displayMessage(json); displayMessage(json + " Error Code : " + response.statusCode); } } catch (Exception e) { e.printStackTrace(); } } } }); jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(30000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); InstiworkApplication.getInstance().addToRequestQueue(jsonObjReq); }
From source file:com.android.mms.transaction.MessagingNotification.java
private static final NotificationInfo getNewIccMessageNotificationInfo(Context context, boolean isSms, String address, String message, String subject, int subId, long timeMillis, Bitmap attachmentBitmap, Contact contact, int attachmentType) { Intent clickIntent = new Intent(context, ManageSimMessages.class); clickIntent.setFlags(// w ww.j a v a2 s . c o m Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); clickIntent.putExtra(PhoneConstants.PHONE_KEY, SubscriptionManager.getPhoneId(subId)); String senderInfo = buildTickerMessage(context, address, null, null).toString(); String senderInfoName = senderInfo.substring(0, senderInfo.length()); CharSequence simName = MessageUtils.getSimName(context, subId); CharSequence ticker = buildTickerMessage(context, address, subject, message); return new NotificationInfo(isSms, clickIntent, message, subject, simName, ticker, timeMillis, senderInfoName, attachmentBitmap, contact, attachmentType, 0); }
From source file:com.secupwn.aimsicd.service.CellTracker.java
/** * Description: Set or update the Detection/Status Notification * TODO: Need to add status HIGH (Orange) and SKULL (Black) * * Issues://from w ww. j ava2s. c o m * See: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/Status-Icons * and: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/11#issuecomment-44670204 * * [ ] We need to standardize the "contentText" and "tickerText" format * * [ ] From #91: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/91 * * Problem: * Having multiple notifications will cause an issue with * notifications themselves AND tickerText. It seems that the * most recent notification raised would overwrite any previous, * notification or tickerText. This results in loss of information * for any notification before the last one. * * Possible Solution: * Perhaps arranging a queue implementation to deal with text * being passed into tickerText only when any previous text has * been entirely displayed. * * Dependencies: Status.java, CellTracker.java, Icon.java ( + others?) * */ void setNotification() { String tickerText; String contentText = "Phone Type " + device.getPhoneType(); if (femtoDetected || typeZeroSmsDetected) { getApplication().setCurrentStatus(Status.DANGER, vibrateEnabled, vibrateMinThreatLevel); } else if (changedLAC) { getApplication().setCurrentStatus(Status.MEDIUM, vibrateEnabled, vibrateMinThreatLevel); contentText = context.getString(R.string.hostile_service_area_changing_lac_detected); } else if (emptyNeighborCellsList) { getApplication().setCurrentStatus(Status.MEDIUM, vibrateEnabled, vibrateMinThreatLevel); contentText = context.getString(R.string.cell_doesnt_provide_any_neighbors); } else if (cellIdNotInOpenDb) { getApplication().setCurrentStatus(Status.MEDIUM, vibrateEnabled, vibrateMinThreatLevel); contentText = context.getString(R.string.cell_id_doesnt_exist_in_db); } else if (trackingFemtocell || trackingCell || monitoringCell) { getApplication().setCurrentStatus(Status.OK, vibrateEnabled, vibrateMinThreatLevel); if (trackingFemtocell) { contentText = context.getString(R.string.femtocell_detection_active); } else if (trackingCell) { contentText = context.getString(R.string.cell_tracking_active); } if (monitoringCell) { contentText = context.getString(R.string.cell_monitoring_active); } else { getApplication().setCurrentStatus(Status.IDLE, vibrateEnabled, vibrateMinThreatLevel); } } else { getApplication().setCurrentStatus(Status.IDLE, vibrateEnabled, vibrateMinThreatLevel); } Status status = getApplication().getStatus(); switch (status) { case IDLE: // GRAY contentText = context.getString(R.string.phone_type) + device.getPhoneType(); tickerText = context.getResources().getString(R.string.app_name_short) + " " + context.getString(R.string.status_idle_description); break; case OK: // GREEN tickerText = context.getResources().getString(R.string.app_name_short) + " " + context.getString(R.string.status_ok_description); break; case MEDIUM: // YELLOW // Initialize tickerText as the app name string // See multiple detection comments above. tickerText = context.getResources().getString(R.string.app_name_short); if (changedLAC) { //Append changing LAC text contentText = context.getString(R.string.hostile_service_area_changing_lac_detected); tickerText += " - " + contentText; } else if (emptyNeighborCellsList) { //According to #264 contentText = context.getString(R.string.cell_doesnt_provide_any_neighbors); tickerText += " - " + contentText; } else if (cellIdNotInOpenDb) { //Append Cell ID not existing in external db text contentText = context.getString(R.string.cell_id_doesnt_exist_in_db); tickerText += " - " + contentText; } break; case DANGER: // RED tickerText = context.getResources().getString(R.string.app_name_short) + " - " + context.getString(R.string.alert_threat_detected); // Hmm, this is vague! if (femtoDetected) { contentText = context.getString(R.string.alert_femtocell_connection_detected); } else if (typeZeroSmsDetected) { contentText = context.getString(R.string.alert_silent_sms_detected); } break; default: tickerText = context.getResources().getString(R.string.main_app_name); break; } // TODO: Explanation (see above) Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.putExtra("silent_sms", typeZeroSmsDetected); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_FROM_BACKGROUND); PendingIntent contentIntent = PendingIntent.getActivity(context, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); String iconType = prefs.getString(context.getString(R.string.pref_ui_icons_key), "SENSE").toUpperCase(); int iconResId = Icon.getIcon(Icon.Type.valueOf(iconType), status); Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), iconResId); int color = context.getResources().getColor(status.getColor()); Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.tower48) .setColor(color).setLargeIcon(largeIcon).setTicker(tickerText) .setContentTitle(context.getString(R.string.status) + " " + context.getString(status.getName())) .setContentInfo(context.getResources().getString(R.string.app_name_short)) .setContentText(contentText).setOngoing(true).setAutoCancel(false).setContentIntent(contentIntent) .build(); NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, notification); }
From source file:dentex.youtube.downloader.ShareActivity.java
public static void NotificationHelper() { pt1 = mContext.getString(R.string.notification_downloading_pt1); pt2 = mContext.getString(R.string.notification_downloading_pt2); noDownloads = mContext.getString(R.string.notification_no_downloads); mBuilder = new NotificationCompat.Builder(mContext); mBuilder.setSmallIcon(R.drawable.ic_stat_ytd) .setContentTitle(mContext.getString(R.string.title_activity_share)) .setContentText(mContext.getString(R.string.notification_downloading_pt1) + " " + sequence.size() + " " + mContext.getString(R.string.notification_downloading_pt2)); mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(android.app.DownloadManager.ACTION_VIEW_DOWNLOADS); if (notificationIntent.resolveActivity(mContext.getPackageManager()) != null) { notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); } else {//from w ww.j av a 2 s. c om Log.e(DEBUG_TAG, "notificationIntent not resolved"); } PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, notificationIntent, 0); mBuilder.setContentIntent(contentIntent); mId = 1; mNotificationManager.notify(mId, mBuilder.build()); }
From source file:im.neon.fragments.VectorMessageListFragment.java
@Override public void onURLClick(Uri uri) { try {//from w ww.j ava 2 s . com if (null != uri) { HashMap<String, String> universalParams = VectorUniversalLinkReceiver.parseUniversalLink(uri); if (null != universalParams) { // open the member sheet from the current activity if (universalParams.containsKey(VectorUniversalLinkReceiver.ULINK_MATRIX_USER_ID_KEY)) { Intent roomDetailsIntent = new Intent(getActivity(), VectorMemberDetailsActivity.class); roomDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MEMBER_ID, universalParams.get(VectorUniversalLinkReceiver.ULINK_MATRIX_USER_ID_KEY)); roomDetailsIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MATRIX_ID, mSession.getCredentials().userId); getActivity().startActivityForResult(roomDetailsIntent, VectorRoomActivity.GET_MENTION_REQUEST_CODE); } else { // pop to the home activity Intent intent = new Intent(getActivity(), VectorHomeActivity.class); intent.setFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP | android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(VectorHomeActivity.EXTRA_JUMP_TO_UNIVERSAL_LINK, uri); getActivity().startActivity(intent); } } else { Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.putExtra(Browser.EXTRA_APPLICATION_ID, getActivity().getPackageName()); getActivity().startActivity(intent); } } } catch (Exception e) { Log.e(LOG_TAG, "## onURLClick() failed " + e.getMessage()); } }
From source file:com.becapps.easydownloader.ShareActivity.java
public static void NotificationHelper() { pt1 = mContext.getString(R.string.notification_downloading_pt1); pt2 = mContext.getString(R.string.notification_downloading_pt2); noDownloads = mContext.getString(R.string.notification_no_downloads); mBuilder = new NotificationCompat.Builder(mContext); mBuilder.setSmallIcon(R.drawable.icon_nb).setContentTitle(mContext.getString(R.string.title_activity_share)) .setContentText(mContext.getString(R.string.notification_downloading_pt1) + " " + sequence.size() + " " + mContext.getString(R.string.notification_downloading_pt2)); mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(android.app.DownloadManager.ACTION_VIEW_DOWNLOADS); if (notificationIntent.resolveActivity(mContext.getPackageManager()) != null) { notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); } else {/*from w w w . j av a2s . com*/ Log.e(DEBUG_TAG, "notificationIntent not resolved"); } PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, notificationIntent, 0); mBuilder.setContentIntent(contentIntent); mId = 1; mNotificationManager.notify(mId, mBuilder.build()); }
From source file:co.beem.project.beem.FacebookTextService.java
private PendingIntent makeChatIntent(User user) { Intent chatIntent = new Intent(FacebookTextService.this, FbTextMainActivity.class); chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); try {/* w w w . j a v a 2 s. c om*/ chatIntent.setData(user.toUri()); } catch (Exception e) { Log.e(TAG, e.getMessage()); } PendingIntent contentIntent = PendingIntent.getActivity(FacebookTextService.this, 0, chatIntent, PendingIntent.FLAG_UPDATE_CURRENT); return contentIntent; }