android.app.PendingIntent.CanceledException Java Examples
The following examples show how to use
android.app.PendingIntent.CanceledException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OktaManagementActivityTest.java From okta-sdk-appauth-android with Apache License 2.0 | 6 votes |
@Test public void testOnStartShouldSignOutIfConfigurationHasChanged() throws CanceledException, JSONException { // Create new configuration to change the hash Context context = RuntimeEnvironment.application.getApplicationContext(); new OAuthClientConfiguration( context, context.getSharedPreferences(OAuthClientConfiguration.PREFS_NAME, MODE_PRIVATE), ConfigurationStreams.getOtherConfiguration() ); doNothing().when(mCancelIntent).send(); OktaManagementActivity activity = Robolectric.buildActivity( OktaManagementActivity.class ).newIntent(createStartIntent()).create().start().get(); assertThat(activity.isFinishing()).isTrue(); }
Example #2
Source File: OktaManagementActivityTest.java From okta-sdk-appauth-android with Apache License 2.0 | 6 votes |
@Test public void testOnStartShouldCompleteIfStateIsAuthorized() throws CanceledException, JSONException { Context context = RuntimeEnvironment.application.getApplicationContext(); AuthStateManager stateManager = AuthStateManager.getInstance(context); stateManager.replace(mAuthState); when(mAuthState.isAuthorized()).thenReturn(true); doNothing().when(mCompleteIntent).send(); OktaManagementActivity activity = Robolectric.buildActivity( OktaManagementActivity.class, createStartIntent() ).create().start().get(); assertThat(activity.isFinishing()).isTrue(); }
Example #3
Source File: AuthorizationManagementActivity.java From AppAuth-Android with Apache License 2.0 | 6 votes |
private void handleAuthorizationComplete() { Uri responseUri = getIntent().getData(); Intent responseData = extractResponseData(responseUri); if (responseData == null) { Logger.error("Failed to extract OAuth2 response from redirect"); return; } responseData.setData(responseUri); if (mCompleteIntent != null) { Logger.debug("Authorization complete - invoking completion intent"); try { mCompleteIntent.send(this, 0, responseData); } catch (CanceledException ex) { Logger.error("Failed to send completion intent", ex); } } else { setResult(RESULT_OK, responseData); } }
Example #4
Source File: AuthorizationManagementActivity.java From AppAuth-Android with Apache License 2.0 | 6 votes |
private void handleAuthorizationCanceled() { Logger.debug("Authorization flow canceled by user"); Intent cancelData = AuthorizationException.fromTemplate( AuthorizationException.GeneralErrors.USER_CANCELED_AUTH_FLOW, null) .toIntent(); if (mCancelIntent != null) { try { mCancelIntent.send(this, 0, cancelData); } catch (CanceledException ex) { Logger.error("Failed to send cancel intent", ex); } } else { setResult(RESULT_CANCELED, cancelData); Logger.debug("No cancel intent set - will return to previous activity"); } }
Example #5
Source File: CustomTabIntentDataProvider.java From 365browser with Apache License 2.0 | 6 votes |
/** * Triggers the client-defined action when the user clicks a custom menu item. * @param menuIndex The index that the menu item is shown in the result of * {@link #getMenuTitles()} */ public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, String url) { Intent addedIntent = new Intent(); addedIntent.setData(Uri.parse(url)); try { // Media viewers pass in PendingIntents that contain CHOOSER Intents. Setting the data // in these cases prevents the Intent from firing correctly. String title = mMenuEntries.get(menuIndex).first; PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second; pendingIntent.send( activity, 0, isMediaViewer() ? null : addedIntent, mOnFinished, null); if (shouldEnableEmbeddedMediaExperience() && TextUtils.equals( title, activity.getString(R.string.download_manager_open_with))) { RecordUserAction.record("CustomTabsMenuCustomMenuItem.DownloadsUI.OpenWith"); } } catch (CanceledException e) { Log.e(TAG, "Custom tab in Chrome failed to send pending intent."); } }
Example #6
Source File: KADataService.java From android-viewer-for-khan-academy with GNU General Public License v3.0 | 5 votes |
private void finish(int startId, PendingIntent pendingIntent, int result) { if (pendingIntent != null) { try { pendingIntent.send(result); } catch (CanceledException e) { // Ignore this. If they don't want their result, they don't get it. } } this.stopSelfResult(startId); }
Example #7
Source File: ActivityManagerTest.java From GPT with Apache License 2.0 | 5 votes |
/** * testGetIntentSender */ private void testGetIntentSender() { Intent intent = new Intent(); intent.setClass(this, AnimationAlphaActivity.class); PendingIntent pi = PendingIntent.getActivity(this, 100, intent, 0); try { pi.send(); } catch (CanceledException e) { if (DEBUG) { e.printStackTrace(); } } }
Example #8
Source File: ResultsActivity.java From BarcodeEye with Apache License 2.0 | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { CardPresenter cardPresenter = mCardPresenters.get(position); PendingIntent pendingIntent = cardPresenter.getPendingIntent(); if (pendingIntent != null) { try { pendingIntent.send(); } catch (CanceledException e) { Log.w(TAG, e.getMessage()); } } else { Log.w(TAG, "No PendingIntent attached to card!"); } }
Example #9
Source File: AndroidListenerIntents.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * Given an authorization token request intent and authorization information ({@code authToken} * and {@code authType}) issues a response. */ static void issueAuthTokenResponse(Context context, PendingIntent pendingIntent, String authToken, String authType) { Intent responseIntent = new Intent() .putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN, authToken) .putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE, authType); try { pendingIntent.send(context, 0, responseIntent); } catch (CanceledException exception) { logger.warning("Canceled auth request: %s", exception); } }
Example #10
Source File: AndroidListenerIntents.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * Given an authorization token request intent and authorization information ({@code authToken} * and {@code authType}) issues a response. */ static void issueAuthTokenResponse(Context context, PendingIntent pendingIntent, String authToken, String authType) { Intent responseIntent = new Intent() .putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN, authToken) .putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE, authType); try { pendingIntent.send(context, 0, responseIntent); } catch (CanceledException exception) { logger.warning("Canceled auth request: %s", exception); } }
Example #11
Source File: IntentActivityFlags.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void onClick(View v) { Context context = IntentActivityFlags.this; PendingIntent pi = PendingIntent.getActivities(context, 0, buildIntentsToViewsLists(), PendingIntent.FLAG_UPDATE_CURRENT); try { pi.send(); } catch (CanceledException e) { Log.w("IntentActivityFlags", "Failed sending PendingIntent", e); } }
Example #12
Source File: WidgetProvider.java From PressureNet with GNU General Public License v3.0 | 5 votes |
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { mContext = context; RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.small_widget_layout); Intent intent = new Intent(context, WidgetButtonService.class); intent.putExtra("msg", mReading + ""); intent.putExtra("widget", "yes"); intent.setAction(ACTION_UPDATEUI); Intent clickIntent = new Intent(context, BarometerNetworkActivity.class); PendingIntent clickPI = PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widgetSmallText, clickPI); remoteViews.setOnClickPendingIntent(R.id.widget_tendency_image_down, clickPI); remoteViews.setOnClickPendingIntent(R.id.widget_tendency_image_steady, clickPI); remoteViews.setOnClickPendingIntent(R.id.widget_tendency_image_up, clickPI); PendingIntent actionPendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widgetSmallSubmitButton, actionPendingIntent); try { actionPendingIntent.send(); } catch(CanceledException ce) { //log(ce.getMessage()); } appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); super.onUpdate(context, appWidgetManager, appWidgetIds); }
Example #13
Source File: SetupIntro.java From android-picturepassword with MIT License | 5 votes |
private void saveData() { if ( !PicturePasswordUtils.saveUnlockData( this, mBitmap, mGridSize, mRandomize, mChosenNumber, mUnlockPosition ) ) { // uh oh finish(); } else { PendingIntent requestedIntent = getIntent().getParcelableExtra( "PendingIntent" ); boolean ok = false; if ( requestedIntent != null ) { try { requestedIntent.send(); ok = true; } catch ( CanceledException e ) { ok = false; } } else { Log.e( "PicturePassword", "PendingIntent was null or canceled! This is probably bad!" ); Intent chooseIntent = new Intent(); chooseIntent.setClassName( "com.android.settings", "com.android.settings.ChooseLockGeneric" ); chooseIntent.putExtra( "lockscreen.biometric_weak_fallback", true ); startActivity( chooseIntent ); } finish(); } }
Example #14
Source File: AndroidListenerIntents.java From 365browser with Apache License 2.0 | 5 votes |
/** * Given an authorization token request intent and authorization information ({@code authToken} * and {@code authType}) issues a response. */ static void issueAuthTokenResponse(Context context, PendingIntent pendingIntent, String authToken, String authType) { Intent responseIntent = new Intent() .putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN, authToken) .putExtra(AuthTokenConstants.EXTRA_AUTH_TOKEN_TYPE, authType); try { pendingIntent.send(context, 0, responseIntent); } catch (CanceledException exception) { logger.warning("Canceled auth request: %s", exception); } }
Example #15
Source File: BrowserActionsContextMenuItemDelegate.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called when a custom item of Browser action menu is selected. * @param action The PendingIntent action to be launched. */ public void onCustomItemSelected(PendingIntent action) { try { action.send(); } catch (CanceledException e) { Log.e(TAG, "Browser Action in Chrome failed to send pending intent."); } }
Example #16
Source File: CustomTabBottomBarDelegate.java From 365browser with Apache License 2.0 | 5 votes |
private static void sendPendingIntentWithUrl(PendingIntent pendingIntent, Intent extraIntent, ChromeActivity activity) { Intent addedIntent = extraIntent == null ? new Intent() : new Intent(extraIntent); Tab tab = activity.getActivityTab(); if (tab != null) addedIntent.setData(Uri.parse(tab.getUrl())); try { pendingIntent.send(activity, 0, addedIntent, null, null); } catch (CanceledException e) { Log.e(TAG, "CanceledException when sending pending intent."); } }
Example #17
Source File: CustomTabIntentDataProvider.java From 365browser with Apache License 2.0 | 5 votes |
/** * Sends the pending intent for the custom button on toolbar with the given url as data. * @param context The context to use for sending the {@link PendingIntent}. * @param url The url to attach as additional data to the {@link PendingIntent}. */ public void sendButtonPendingIntentWithUrl(Context context, String url) { Intent addedIntent = new Intent(); addedIntent.setData(Uri.parse(url)); try { getCustomButtonOnToolbar().getPendingIntent().send(context, 0, addedIntent, mOnFinished, null); } catch (CanceledException e) { Log.e(TAG, "CanceledException while sending pending intent in custom tab"); } }
Example #18
Source File: BrowserActionsFallbackMenuUi.java From custom-tabs-client with Apache License 2.0 | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { BrowserActionItem menuItem = mMenuItems.get(position); if (menuItem.getAction() != null) { try { menuItem.getAction().send(); } catch (CanceledException e) { Log.e(TAG, "Failed to send custom item action", e); } } else if (menuItem.getRunnableAction() != null) { menuItem.getRunnableAction().run(); } mBrowserActionsDialog.dismiss(); }
Example #19
Source File: GPSUtils.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
/** * <p> * GPS开关 * <p> * 当前若关则打开 * <p> * 当前若开则关闭 */ public static void toggleGPS(Context context) { Intent gpsIntent = new Intent(); gpsIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); gpsIntent.addCategory("android.intent.category.ALTERNATIVE"); gpsIntent.setData(Uri.parse("custom:3")); try { PendingIntent.getBroadcast(context, 0, gpsIntent, 0).send(); } catch (CanceledException e) { e.printStackTrace(); } }
Example #20
Source File: CustomTabBottomBarDelegate.java From AndroidChromium with Apache License 2.0 | 5 votes |
private static void sendPendingIntentWithUrl(PendingIntent pendingIntent, Intent extraIntent, ChromeActivity activity) { Intent addedIntent = extraIntent == null ? new Intent() : new Intent(extraIntent); Tab tab = activity.getActivityTab(); if (tab != null) addedIntent.setData(Uri.parse(tab.getUrl())); try { pendingIntent.send(activity, 0, addedIntent, null, null); } catch (CanceledException e) { Log.e(TAG, "CanceledException when sending pending intent."); } }
Example #21
Source File: CustomTabIntentDataProvider.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Sends the pending intent for the custom button on toolbar with the given url as data. * @param context The context to use for sending the {@link PendingIntent}. * @param url The url to attach as additional data to the {@link PendingIntent}. */ public void sendButtonPendingIntentWithUrl(Context context, String url) { Intent addedIntent = new Intent(); addedIntent.setData(Uri.parse(url)); try { getCustomButtonOnToolbar().getPendingIntent().send(context, 0, addedIntent, mOnFinished, null); } catch (CanceledException e) { Log.e(TAG, "CanceledException while sending pending intent in custom tab"); } }
Example #22
Source File: CustomTabIntentDataProvider.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Triggers the client-defined action when the user clicks a custom menu item. * @param menuIndex The index that the menu item is shown in the result of * {@link #getMenuTitles()} */ public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, String url) { Intent addedIntent = new Intent(); addedIntent.setData(Uri.parse(url)); try { // Media viewers pass in PendingIntents that contain CHOOSER Intents. Setting the data // in these cases prevents the Intent from firing correctly. PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second; pendingIntent.send( activity, 0, isMediaViewer() ? null : addedIntent, mOnFinished, null); } catch (CanceledException e) { Log.e(TAG, "Custom tab in Chrome failed to send pending intent."); } }
Example #23
Source File: CustomTabBottomBarDelegate.java From delion with Apache License 2.0 | 5 votes |
private static void sendPendingIntentWithUrl(PendingIntent pendingIntent, Intent extraIntent, ChromeActivity activity) { Intent addedIntent = extraIntent == null ? new Intent() : new Intent(extraIntent); Tab tab = activity.getActivityTab(); if (tab != null) addedIntent.setData(Uri.parse(tab.getUrl())); try { pendingIntent.send(activity, 0, addedIntent, null, null); } catch (CanceledException e) { Log.e(TAG, "CanceledException when sending pending intent."); } }
Example #24
Source File: CustomTabIntentDataProvider.java From delion with Apache License 2.0 | 5 votes |
/** * Sends the pending intent for the custom button on toolbar with the given url as data. * @param context The context to use for sending the {@link PendingIntent}. * @param url The url to attach as additional data to the {@link PendingIntent}. */ public void sendButtonPendingIntentWithUrl(Context context, String url) { Intent addedIntent = new Intent(); addedIntent.setData(Uri.parse(url)); try { getCustomButtonOnToolbar().getPendingIntent().send(context, 0, addedIntent, mOnFinished, null); } catch (CanceledException e) { Log.e(TAG, "CanceledException while sending pending intent in custom tab"); } }
Example #25
Source File: CustomTabIntentDataProvider.java From delion with Apache License 2.0 | 5 votes |
/** * Triggers the client-defined action when the user clicks a custom menu item. * @param menuIndex The index that the menu item is shown in the result of * {@link #getMenuTitles()} */ public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, String url) { Intent addedIntent = new Intent(); addedIntent.setData(Uri.parse(url)); try { PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second; pendingIntent.send(activity, 0, addedIntent, mOnFinished, null); } catch (CanceledException e) { Log.e(TAG, "Custom tab in Chrome failed to send pending intent."); } }