List of usage examples for android.content Intent URI_INTENT_SCHEME
int URI_INTENT_SCHEME
To view the source code for android.content Intent URI_INTENT_SCHEME.
Click Source Link
From source file:de.azapps.mirakel.sync.taskwarrior.services.SyncAdapter.java
/** * Shows the Notification with the error message if needed * * @param showNotification/*from www . j a v a2 s . c om*/ * @param success * @throws ClassNotFoundException */ private void handleError(final boolean showNotification, final boolean success) throws ClassNotFoundException { if (showNotification && !success) { final String title = "Mirakel: " + this.mContext.getText(R.string.finish_sync); final Intent openIntent = new Intent(this.mContext, Class.forName(DefinitionsHelper.MAINACTIVITY_CLASS)); openIntent.setAction(DefinitionsHelper.SHOW_MESSAGE); openIntent.putExtra(Intent.EXTRA_SUBJECT, title); openIntent.putExtra(Intent.EXTRA_TEXT, last_message); openIntent.setData(Uri.parse(openIntent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent pOpenIntent = PendingIntent.getActivity(this.mContext, 0, openIntent, PendingIntent.FLAG_UPDATE_CURRENT); final Notification notification = new NotificationCompat.Builder(this.mContext).setContentTitle(title) .setContentText(last_message).setSmallIcon(android.R.drawable.stat_notify_sync) .setPriority(NotificationCompat.PRIORITY_LOW).setContentIntent(pOpenIntent).build(); notification.flags = Notification.FLAG_AUTO_CANCEL; this.mNotificationManager.notify(SyncAdapter.NOTIFY_ID, notification); } }
From source file:de.baumann.browser.helper.helper_webView.java
public static void webView_WebViewClient(final Activity from, final SwipeRefreshLayout swipeRefreshLayout, final WebView webView, final EditText editText) { webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); swipeRefreshLayout.setRefreshing(false); editText.setText(webView.getTitle()); if (webView.getTitle() != null && !webView.getTitle().equals("about:blank")) { try { final Database_History db = new Database_History(from); db.addBookmark(webView.getTitle(), webView.getUrl()); db.close();//from w ww.j av a2 s . c o m } catch (Exception e) { e.printStackTrace(); } } } @SuppressWarnings("deprecation") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { final Uri uri = Uri.parse(url); return handleUri(uri); } @TargetApi(Build.VERSION_CODES.N) @Override public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { final Uri uri = request.getUrl(); return handleUri(uri); } private boolean handleUri(final Uri uri) { Log.i(TAG, "Uri =" + uri); final String url = uri.toString(); // Based on some condition you need to determine if you are going to load the url // in your web view itself or in a browser. // You can use `host` or `scheme` or any part of the `uri` to decide. if (url.startsWith("http")) return false;//open web links as usual //try to find browse activity to handle uri Uri parsedUri = Uri.parse(url); PackageManager packageManager = from.getPackageManager(); Intent browseIntent = new Intent(Intent.ACTION_VIEW).setData(parsedUri); if (browseIntent.resolveActivity(packageManager) != null) { from.startActivity(browseIntent); return true; } //if not activity found, try to parse intent:// if (url.startsWith("intent:")) { try { Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); if (intent.resolveActivity(from.getPackageManager()) != null) { from.startActivity(intent); return true; } //try to find fallback url String fallbackUrl = intent.getStringExtra("browser_fallback_url"); if (fallbackUrl != null) { webView.loadUrl(fallbackUrl); return true; } //invite to install Intent marketIntent = new Intent(Intent.ACTION_VIEW) .setData(Uri.parse("market://details?id=" + intent.getPackage())); if (marketIntent.resolveActivity(packageManager) != null) { from.startActivity(marketIntent); return true; } } catch (URISyntaxException e) { //not an intent uri } } return true;//do nothing in other cases } }); }
From source file:de.azapps.mirakel.reminders.ReminderAlarm.java
private static PendingIntent updateAlarm(final Context ctx, final Task task) { final Intent intent = new Intent(ctx, ReminderAlarm.class); intent.setAction(SHOW_TASK);//w w w.j a v a 2 s . c o m intent.putExtra(EXTRA_ID, task.getId()); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent pendingIntent = PendingIntent.getBroadcast(ctx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); if ((pendingIntent == null) || !task.getReminder().isPresent()) { return null; } Log.v(TAG, "Set alarm for " + task.getName() + " on " + task.getReminder().get().getTimeInMillis()); final Optional<Recurring> recurringReminder = task.getRecurringReminder(); if (!recurringReminder.isPresent()) { alarmManager.set(AlarmManager.RTC_WAKEUP, task.getReminder().get().getTimeInMillis(), pendingIntent); } else { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, task.getReminder().get().getTimeInMillis(), recurringReminder.get().getInterval(), pendingIntent); } return pendingIntent; }
From source file:org.mozilla.gecko.overlays.ui.ShareDialog.java
public void launchBrowser() { try {/* ww w . j a v a 2s. c om*/ // This can launch in the guest profile. Sorry. final Intent i = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); i.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS); startActivity(i); } catch (URISyntaxException e) { // Nothing much we can do. } finally { slideOut(); } }
From source file:com.google.android.apps.muzei.provider.MuzeiProvider.java
private Uri insertArtwork(@NonNull final Uri uri, final ContentValues values) { Context context = getContext(); if (context == null) { return null; }// ww w . j a v a 2 s . c o m if (values == null) { throw new IllegalArgumentException("Invalid ContentValues: must not be null"); } if (!values.containsKey(MuzeiContract.Artwork.COLUMN_NAME_SOURCE_COMPONENT_NAME) || TextUtils.isEmpty(values.getAsString(MuzeiContract.Artwork.COLUMN_NAME_SOURCE_COMPONENT_NAME))) { throw new IllegalArgumentException("Initial values must contain component name: " + values); } // Check to make sure the component name is valid ComponentName componentName = ComponentName .unflattenFromString(values.getAsString(MuzeiContract.Artwork.COLUMN_NAME_SOURCE_COMPONENT_NAME)); if (componentName == null) { throw new IllegalArgumentException("Invalid component name: " + values.getAsString(MuzeiContract.Artwork.COLUMN_NAME_SOURCE_COMPONENT_NAME)); } // Make sure they are using the short string format values.put(MuzeiContract.Artwork.COLUMN_NAME_SOURCE_COMPONENT_NAME, componentName.flattenToShortString()); // Ensure the app inserting the artwork is either Muzei or the same app as the source String callingPackageName = getCallingPackage(); if (!context.getPackageName().equals(callingPackageName) && !TextUtils.equals(callingPackageName, componentName.getPackageName())) { throw new IllegalArgumentException("Calling package name (" + callingPackageName + ") must match the source's package name (" + componentName.getPackageName() + ")"); } if (values.containsKey(MuzeiContract.Artwork.COLUMN_NAME_VIEW_INTENT)) { String viewIntentString = values.getAsString(MuzeiContract.Artwork.COLUMN_NAME_VIEW_INTENT); Intent viewIntent; try { if (!TextUtils.isEmpty(viewIntentString)) { // Make sure it is a valid Intent URI viewIntent = Intent.parseUri(viewIntentString, Intent.URI_INTENT_SCHEME); // Make sure we can construct a PendingIntent for the Intent PendingIntent.getActivity(context, 0, viewIntent, PendingIntent.FLAG_UPDATE_CURRENT); } } catch (URISyntaxException e) { Log.w(TAG, "Removing invalid View Intent: " + viewIntentString, e); values.remove(MuzeiContract.Artwork.COLUMN_NAME_VIEW_INTENT); } catch (RuntimeException e) { // This is actually meant to catch a FileUriExposedException, but you can't // have catch statements for exceptions that don't exist at your minSdkVersion Log.w(TAG, "Removing invalid View Intent that contains a file:// URI: " + viewIntentString, e); values.remove(MuzeiContract.Artwork.COLUMN_NAME_VIEW_INTENT); } } // Ensure the related source has been added to the database. // This should be true in 99.9% of cases, but the insert will fail if this isn't true Cursor sourceQuery = querySource(MuzeiContract.Sources.CONTENT_URI, new String[] { BaseColumns._ID }, MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME + "=?", new String[] { componentName.flattenToShortString() }, null); if (sourceQuery == null || sourceQuery.getCount() == 0) { ContentValues initialValues = new ContentValues(); initialValues.put(MuzeiContract.Sources.COLUMN_NAME_COMPONENT_NAME, componentName.flattenToShortString()); insertSource(MuzeiContract.Sources.CONTENT_URI, initialValues); } if (sourceQuery != null) { sourceQuery.close(); } values.put(MuzeiContract.Artwork.COLUMN_NAME_DATE_ADDED, System.currentTimeMillis()); final SQLiteDatabase db = databaseHelper.getWritableDatabase(); long rowId = db.insert(MuzeiContract.Artwork.TABLE_NAME, MuzeiContract.Artwork.COLUMN_NAME_IMAGE_URI, values); // If the insert succeeded, the row ID exists. if (rowId > 0) { // Creates a URI with the artwork ID pattern and the new row ID appended to it. final Uri artworkUri = ContentUris.withAppendedId(MuzeiContract.Artwork.CONTENT_URI, rowId); File artwork = getCacheFileForArtworkUri(artworkUri); if (artwork != null && artwork.exists()) { // The image already exists so we'll notifyChange() to say the new artwork is ready // Otherwise, this will be called when the file is written with openFile() // using this Uri and the actual artwork is written successfully notifyChange(artworkUri); } return artworkUri; } // If the insert didn't succeed, then the rowID is <= 0 throw new SQLException("Failed to insert row into " + uri); }
From source file:com.android.messaging.ui.UIIntentsImpl.java
@Override public PendingIntent getWidgetPendingIntentForConfigurationActivity(final Context context, final int appWidgetId) { final Intent configureIntent = new Intent(context, WidgetPickConversationActivity.class); configureIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); configureIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE); configureIntent.setData(Uri.parse(configureIntent.toUri(Intent.URI_INTENT_SCHEME))); configureIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY); return getPendingIntentWithParentStack(context, configureIntent, 0); }
From source file:uk.co.ashtonbrsc.intentexplode.Explode.java
private static String getUri(Intent src) { return (src != null) ? src.toUri(Intent.URI_INTENT_SCHEME) : null; }
From source file:uk.co.ashtonbrsc.intentexplode.Explode.java
private Intent cloneIntent(String intentUri) { if (intentUri != null) { try {//from w w w. j av a2 s . c o m Intent clone = Intent.parseUri(intentUri, Intent.URI_INTENT_SCHEME); // bugfix #14: restore extras that are lost in the intent <-> string conversion if (additionalExtras != null) { clone.putExtras(additionalExtras); } return clone; } catch (URISyntaxException e) { e.printStackTrace(); } } return null; }
From source file:org.restcomm.android.sdk.RCDevice.java
/** * Initialize RCDevice (if not already initialized) the RCDevice Service with parameters. Notice that this needs to happen after the service has been bound. Remember that * once the Service starts in continues to run in the background even if the App doesn't have any activity running * * @param activityContext Activity context * @param parameters Parameters for the Device entity (prefer using the string constants shown below, i.e. RCDevice.ParameterKeys.*, instead of * using strings like 'signaling-secure', etc. Possible keys: <br> * <b>RCDevice.ParameterKeys.SIGNALING_USERNAME</b>: Identity for the client, like <i>'bob'</i> (mandatory) <br> * <b>RCDevice.ParameterKeys.SIGNALING_PASSWORD</b>: Password for the client (optional for registrar-less scenarios). Be VERY careful to securely handle this inside your App. Never store it statically and in cleartext form in your App before submitting to Google Play Store as you run the risk of any of the folks downloading it figuring it out your credentials <br> * <b>RCDevice.ParameterKeys.SIGNALING_DOMAIN</b>: Restcomm endpoint to use, like <i>'cloud.restcomm.com'</i>. By default port 5060 will be used for cleartext signaling and 5061 for encrypted signaling. You can override the port by suffixing the domain; for example to use port 5080 instead, use the following: <i>'cloud.restcomm.com:5080'</i>. Don't pass this parameter (or leave empty) for registrar-less mode (optional) <br> * <b>RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE</b>: Media ICE server discovery type, or how should SDK figure out which the actual set ICE servers to use internally. Use ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2 to utilize a V2 Xirsys configuration URL to retrieve the ICE servers. Use ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3 to utilize a V3 Xirsys configuration URL to retrieve the ICE servers. Use ICE_SERVERS_CUSTOM if you don't want to use a configuration URL, but instead provide the set of ICE servers youself to the SDK (i.e. the App needs to have logic to retrieve them and provide them) <br> * <b>RCDevice.ParameterKeys.MEDIA_ICE_URL</b>: ICE url to use when using a Xirsys configuration URL, like <i>'https://service.xirsys.com/ice'</i> for Xirsys V2 (i.e. ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2), and <i>https://es.xirsys.com/_turn/</i> for Xirsys V3 (i.e. ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3). If no Xirsys configuration URL is used (i.e. ICE_SERVERS_CUSTOM) then this key is not applicable shouldn't be passed (optional) <br> * <b>RCDevice.ParameterKeys.MEDIA_ICE_USERNAME</b>: ICE username for authentication when using a Xirsys configuration URL (optional) <br> * <b>RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD</b>: ICE password for authentication when using a Xirsys configuration URL (optional). Be VERY careful to securely handle this inside your App. Never store it statically and in cleartext form in your App before submitting to Google Play Store as you run the risk of any of the folks downloading it figuring it out your credentials <br> * <b>RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN</b>: ICE Domain to be used in the ICE configuration URL when using a Xirsys configuration URL. Notice that V2 Domains are called Channels in V3 organization, but we use this same key in both cases (optional) <br> * <b>RCDevice.ParameterKeys.SIGNALING_SECURE_ENABLED</b>: Should signaling traffic be encrypted? Always set this to true, unless you have a very good reason to use cleartext signaling (like debugging). If this is the case, then a key pair is generated when * signaling facilities are initialized and added to a custom keystore. Also, added to this custom keystore are all the trusted certificates from * the System Wide Android CA Store, so that we properly accept only legit server certificates. If not passed (or false) signaling is cleartext (optional) <br> * <b>RCDevice.ParameterKeys.MEDIA_TURN_ENABLED</b>: Should TURN be enabled for webrtc media? (optional) <br> * <b>RCDevice.ParameterKeys.SIGNALING_LOCAL_PORT</b>: Local port to use for signaling (optional) <br> * <b>RCDevice.ParameterKeys.RESOURCE_SOUND_CALLING</b>: The SDK provides the user with default sounds for calling, ringing, busy (declined) and message events, but the user can override them * by providing their own resource files (i.e. .wav, .mp3, etc) at res/raw passing them here with Resource IDs like R.raw.user_provided_calling_sound. This parameter * configures the sound you will hear when you make a call and until the call is either replied or you hang up<br> * <b>RCDevice.ParameterKeys.RESOURCE_SOUND_RINGING</b>: The sound you will hear when you receive a call <br> * <b>RCDevice.ParameterKeys.RESOURCE_SOUND_DECLINED</b>: The sound you will hear when your call is declined <br> * <b>RCDevice.ParameterKeys.RESOURCE_SOUND_MESSAGE</b>: The sound you will hear when you receive a message <br> * * //push notification keys * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME</b>: name of the client application * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL</b>: account's email * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD </b>: password for an account * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT</b>: true if we want to enable push on server for the account, otherwise false * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_PUSH_DOMAIN</b>: domain for the push notifications; for example: push.restcomm.com * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_HTTP_DOMAIN</b>: Restcomm HTTP domain, like 'cloud.restcomm.com' * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY</b>: server hash key for created application in firebase cloud messaging * <b>RCDevice.ParameterKeys.PUSH_NOTIFICATION_TIMEOUT_MESSAGING_SERVICE</b>: RCDevice will have timer introduced for closing because of the message background logic this is introduced in the design. The timer by default will be 5 seconds; It can be changed by sending parameter with value (in milliseconds) //from ww w .j av a2s .co m * @param deviceListener The listener for upcoming RCDevice events * @return True always for now * @see RCDevice */ public boolean initialize(Context activityContext, HashMap<String, Object> parameters, RCDeviceListener deviceListener) throws RCException { try { if (!isServiceInitialized) { isServiceInitialized = true; //context = activityContext; state = DeviceState.OFFLINE; RCLogger.i(TAG, "RCDevice(): " + parameters.toString()); //this.updateCapabilityToken(capabilityToken); this.listener = deviceListener; RCUtils.validateDeviceParms(parameters); storageManagerPreferences = new StorageManagerPreferences(this); StorageUtils.saveParams(storageManagerPreferences, parameters); //because intents are saved as uri strings we need to check; do we have an //actual intent. If not, we must check is it a string and return an intent Object callObj = parameters.get(RCDevice.ParameterKeys.INTENT_INCOMING_CALL); Object messageObj = parameters.get(RCDevice.ParameterKeys.INTENT_INCOMING_MESSAGE); if (callObj instanceof String && messageObj instanceof String) { Intent intentCall; Intent intentMessage; try { intentCall = Intent.parseUri((String) callObj, Intent.URI_INTENT_SCHEME); } catch (URISyntaxException e) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_REGISTER_INTENT_CALL_MISSING); } try { intentMessage = Intent.parseUri((String) messageObj, Intent.URI_INTENT_SCHEME); } catch (URISyntaxException e) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_REGISTER_INTENT_MESSAGE_MISSING); } setIntents(intentCall, intentMessage); } else if (callObj instanceof Intent && messageObj instanceof Intent) { setIntents((Intent) callObj, (Intent) messageObj); } //set messages timer if (parameters.get(ParameterKeys.PUSH_NOTIFICATION_TIMEOUT_MESSAGING_SERVICE) != null) { messageTimeOutIntervalLimit = (long) parameters .get(ParameterKeys.PUSH_NOTIFICATION_TIMEOUT_MESSAGING_SERVICE); } connections = new HashMap<String, RCConnection>(); //if there is already data for registering to push, dont clear it (onOpenReply is using this parameter) // initialize JAIN SIP if we have connectivity this.parameters = parameters; // initialize registration FSM before we start signaling and push notification registrations // important: needs to happen *before* signaling and push registration startRegistrationFsm(); // check if TURN keys are there //params.put(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED, prefs.getBoolean(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED, true)); if (signalingClient == null) { signalingClient = new SignalingClient(); signalingClient.open(this, getApplicationContext(), parameters); } registerForPushNotifications(false); if (audioManager == null) { // Create and audio manager that will take care of audio routing, // audio modes, audio device enumeration etc. audioManager = AppRTCAudioManager.create(getApplicationContext(), new Runnable() { // This method will be called each time the audio state (number and // type of devices) has been changed. @Override public void run() { onAudioManagerChangedState(); } }); // Store existing audio settings and change audio mode to // MODE_IN_COMMUNICATION for best possible VoIP performance. RCLogger.d(TAG, "Initializing the audio manager..."); audioManager.init(parameters); } } else { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_ALREADY_INITIALIZED); } return false; } catch (RCException e) { isServiceInitialized = false; throw e; } }
From source file:org.restcomm.android.sdk.RCDevice.java
void onNotificationIntent(Intent intent) { String intentAction = intent.getAction(); //if (!intentAction.equals(ACTION_NOTIFICATION_MESSAGE_DEFAULT)) { if (intentAction.equals(ACTION_NOTIFICATION_CALL_DEFAULT) || intentAction.equals(ACTION_NOTIFICATION_CALL_ACCEPT_VIDEO) || intentAction.equals(ACTION_NOTIFICATION_CALL_ACCEPT_AUDIO) || intentAction.equals(ACTION_NOTIFICATION_CALL_DECLINE) || intentAction.equals(ACTION_NOTIFICATION_CALL_DELETE)) { // The user has acted on a call notification, let's cancel it String username = intent.getStringExtra(EXTRA_DID).replaceAll(".*?sip:", "").replaceAll("@.*$", ""); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(callNotifications.get(username)); //callNotifications.remove(username); activeCallNotification = false;/*from ww w . j a va 2 s. co m*/ } Intent actionIntent = null; /* if (intentAction.equals(ACTION_NOTIFICATION_CALL_OPEN)) { RCConnection connection = getLiveConnection(); if (connection != null) { if (connection.isIncoming()) { callIntent.setAction(ACTION_INCOMING_CALL); } else { callIntent.setAction(ACTION_OUTGOING_CALL); } callIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); // don't forget to copy the extras to callIntent callIntent.putExtras(intent); actionIntent = callIntent; } } */ if (intentAction.equals(ACTION_NOTIFICATION_CALL_DEFAULT)) { if (callIntent != null) { callIntent.setAction(ACTION_INCOMING_CALL); // don't forget to copy the extras to callIntent callIntent.putExtras(intent); actionIntent = callIntent; } else { Context context = getApplicationContext(); PackageManager packageManager = context.getPackageManager(); actionIntent = packageManager.getLaunchIntentForPackage(context.getPackageName()); } } else if (intentAction.equals(ACTION_NOTIFICATION_CALL_ACCEPT_VIDEO)) { callIntent.setAction(ACTION_INCOMING_CALL_ANSWER_VIDEO); // don't forget to copy the extras callIntent.putExtras(intent); actionIntent = callIntent; } else if (intentAction.equals(ACTION_NOTIFICATION_CALL_ACCEPT_AUDIO)) { callIntent.setAction(ACTION_INCOMING_CALL_ANSWER_AUDIO); // don't forget to copy the extras callIntent.putExtras(intent); actionIntent = callIntent; } else if (intentAction.equals(ACTION_NOTIFICATION_CALL_DECLINE) || intentAction.equals(ACTION_NOTIFICATION_CALL_DELETE)) { RCConnection pendingConnection = getPendingConnection(); if (pendingConnection != null) { pendingConnection.reject(); } release(); // if the call has been requested to be declined, we shouldn't do any UI handling return; } else if (intentAction.equals(ACTION_NOTIFICATION_CALL_MUTE_AUDIO)) { RCConnection liveConnection = getLiveConnection(); if (liveConnection != null) { if (liveConnection.isAudioMuted()) { liveConnection.setAudioMuted(false); } else { liveConnection.setAudioMuted(true); } } // if the call has been requested to be muted, we shouldn't do any UI handling return; } else if (intentAction.equals(ACTION_NOTIFICATION_CALL_DISCONNECT)) { RCConnection liveConnection = getLiveConnection(); if (liveConnection != null) { liveConnection.disconnect(); if (!isAttached()) { // if the call has been requested to be disconnected, we shouldn't do any UI handling callIntent.setAction(ACTION_CALL_DISCONNECT); //callIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); actionIntent = callIntent; startActivity(actionIntent); } /* // Important if we just trigger the call intent, then after the call is disconnected we will land to the previous screen in // that Task Stack, which is not what we want. Instead, we want the call activity to be finished and to just remain where // we were. To do that we need to create a new Task Stack were we only place the call activity TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the target Intent to the top of the stack stackBuilder.addNextIntent(actionIntent); // Gets a PendingIntent containing the entire back stack, but with Component as the active Activity PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); try { resultPendingIntent.send(); } catch (PendingIntent.CanceledException e) { throw new RuntimeException("Pending Intent cancelled", e); } */ } return; } else if (intentAction.equals(ACTION_NOTIFICATION_MESSAGE_DEFAULT)) { if (messageIntent == null) { storageManagerPreferences = new StorageManagerPreferences(this); String messageIntentString = storageManagerPreferences .getString(RCDevice.ParameterKeys.INTENT_INCOMING_MESSAGE, null); if (messageIntentString != null) { try { messageIntent = Intent.parseUri(messageIntentString, Intent.URI_INTENT_SCHEME); //service was stopped and user taps on Notification case if (!isInitialized()) { HashMap<String, Object> parameters = StorageUtils.getParams(storageManagerPreferences); try { initialize(null, parameters, null); } catch (RCException e) { RCLogger.e(TAG, e.toString()); } } } catch (URISyntaxException e) { throw new RuntimeException("Failed to handle Notification"); } } } messageIntent.setAction(ACTION_INCOMING_MESSAGE); // don't forget to copy the extras messageIntent.putExtras(intent); actionIntent = messageIntent; //we want to stop foreground (notification is tapped) stopForeground(true); stopRepeatingTask(); } else { throw new RuntimeException("Failed to handle Notification"); } // We need to create a Task Stack to make sure we maintain proper flow at all times TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds either call or message intent's Component in the stack together with all its parent activities (remember that for this to work the App Manifest needs to describe their relationship) stackBuilder.addParentStack(actionIntent.getComponent()); // Adds the target Intent to the top of the stack stackBuilder.addNextIntent(actionIntent); // Gets a PendingIntent containing the entire back stack, but with Component as the active Activity PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); try { resultPendingIntent.send(); } catch (PendingIntent.CanceledException e) { throw new RuntimeException("Pending Intent cancelled", e); } }