Java Code Examples for android.app.PendingIntent#send()
The following examples show how to use
android.app.PendingIntent#send() .
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: dex_smali.java From stynico with MIT License | 6 votes |
/** 打开通知栏消息*/ private void openNotify(AccessibilityEvent event) { if (event.getParcelableData() == null || !(event.getParcelableData() instanceof Notification)) { return; } Notification notification = (Notification) event.getParcelableData(); PendingIntent pendingIntent = notification.contentIntent; try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } }
Example 2
Source File: SampleMediaRouteProvider.java From V.FlyoutTest with MIT License | 6 votes |
private void handleStatusChange(PlaylistItem item) { if (item == null) { item = mSessionManager.getCurrentItem(); } if (item != null) { PendingIntent receiver = item.getUpdateReceiver(); if (receiver != null) { Intent intent = new Intent(); intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, item.getSessionId()); intent.putExtra(MediaControlIntent.EXTRA_ITEM_ID, item.getItemId()); intent.putExtra(MediaControlIntent.EXTRA_ITEM_STATUS, item.getStatus().asBundle()); try { receiver.send(getContext(), 0, intent); Log.d(TAG, mRouteId + ": Sending status update from provider"); } catch (PendingIntent.CanceledException e) { Log.d(TAG, mRouteId + ": Failed to send status update!"); } } } }
Example 3
Source File: SuntimesActivityTest.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
@Test public void test_fullUpdateReciever() { // test PendingIntent final SuntimesActivity activity = (SuntimesActivity)activityRule.getActivity(); PendingIntent fullUpdateIntent = activity.getFullUpdateIntent(activity); try { fullUpdateIntent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); fail("CanceledException!"); } // test receiver activity.runOnUiThread(new Runnable() { @Override public void run() { activity.fullUpdateReceiver.onReceive(activity, new Intent(SuntimesActivity.SUNTIMES_APP_UPDATE_FULL)); activity.finish(); assertTrue("app hasn't crashed", activity.isFinishing()); } }); }
Example 4
Source File: SkeletonTracker.java From Easer with GNU General Public License v3.0 | 6 votes |
protected final void newSatisfiedState(Boolean newState) { lck_satisfied.lock(); try { if (satisfied == newState) { return; } satisfied = newState; if (satisfied == null) return; PendingIntent pendingIntent = satisfied ? event_positive : event_negative; try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { Logger.wtf("PendingIntent for notify in SkeletonTracker cancelled before sending???"); e.printStackTrace(); } } finally { lck_satisfied.unlock(); } }
Example 5
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 6
Source File: SavedNewsWidget.java From NewsApp with GNU General Public License v3.0 | 5 votes |
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Intent nextIntent = new Intent(context, SavedNewsService.class); nextIntent.setAction(SavedNewsService.ACTION_GET_NEXT); nextIntent.putExtra(SavedNewsService.PARAM_CURRENT, -1); PendingIntent nextPendingIntent = PendingIntent.getService(context, 0, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT); try { nextPendingIntent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } }
Example 7
Source File: NotificationService.java From luckymoney with Apache License 2.0 | 5 votes |
@Override public void onNotificationPosted(StatusBarNotification sbn) { Notification notification = sbn.getNotification(); if (null == notification) return; Bundle extras = notification.extras; if (null == extras) return; List<String> textList = new ArrayList<>(); String title = extras.getString("android.title"); if (!isEmpty(title)) textList.add(title); String detailText = extras.getString("android.text"); if (!isEmpty(detailText)) textList.add(detailText); if (textList.size() == 0) return; for (String text : textList) { if (!isEmpty(text) && text.contains("[微信红包]")) { final PendingIntent pendingIntent = notification.contentIntent; try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { } break; } } }
Example 8
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 9
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 10
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 11
Source File: ScreenshotDecorator.java From EnhancedScreenshotNotification with GNU General Public License v3.0 | 5 votes |
private void dismissAfterSharing(PendingIntent originalIntent) { try { originalIntent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); if (isOrderedBroadcast()) { try { abortBroadcast(); } catch (RuntimeException ignored) { } } } }
Example 12
Source File: PendingIntentUtils.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
/** * Perform the operation associated with this PendingIntent. */ public static boolean sendPendingIntent(@Nullable PendingIntent pi, Context context, Intent intent) { if (pi != null) try { // The Context of the caller may be null if // <var>intent</var> is also null. Check.getInstance().isTrue(context != null || intent == null); //noinspection ConstantConditions pi.send(context, 0, intent); return true; } catch (PendingIntent.CanceledException e) { /* unused */ } return false; }
Example 13
Source File: TextClassification.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Creates an OnClickListener that triggers the specified PendingIntent. * * @hide */ public static OnClickListener createIntentOnClickListener(@NonNull final PendingIntent intent) { Preconditions.checkNotNull(intent); return v -> { try { intent.send(); } catch (PendingIntent.CanceledException e) { Log.e(LOG_TAG, "Error sending PendingIntent", e); } }; }
Example 14
Source File: MainActivity.java From astrobee_android with Apache License 2.0 | 5 votes |
public void onClickStartRfidReader(View v) { Log.i("onClickStartRfidReader", "Yay I was clicked."); mFullName.setText("Start RFID Reader button pushed!"); if (intents.containsKey("gov.nasa.arc.irg.test_rfid_reader")) { PendingIntent start_apk_intent = intents.get("gov.nasa.arc.irg.test_rfid_reader"); try { start_apk_intent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } else { Log.e("MainActivity", "Couldn't start rfid apk since we don't have the pending intent."); } }
Example 15
Source File: RedEnvelopeHelper.java From RedEnvelopeAssistant with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void openNotification(AccessibilityEvent event) { if( !(event.getParcelableData() instanceof Notification)) { return; } Notification notification = (Notification) event.getParcelableData(); PendingIntent pendingIntent = notification.contentIntent; try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } }
Example 16
Source File: MmsServiceBroker.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void returnPendingIntentWithError(PendingIntent pendingIntent) { try { pendingIntent.send(mContext, SmsManager.MMS_ERROR_UNSPECIFIED, null); } catch (PendingIntent.CanceledException e) { Slog.e(TAG, "Failed to return pending intent result", e); } }
Example 17
Source File: LauncherApplication.java From SoloPi with Apache License 2.0 | 5 votes |
/** * 返回SoloPi */ public void moveSelfToFront() { int contextFrom = 0; // 一级一级加载Context Context context = loadActivityOnTop(); if (context == null) { context = loadRunningService(); contextFrom = 1; } if (context == null) { context = getApplicationContext(); contextFrom = 2; } if (contextFrom != 0) { //获取ActivityManager ActivityManager mAm = (ActivityManager) getSystemService(ACTIVITY_SERVICE); //获得当前运行的task List<ActivityManager.RunningTaskInfo> taskList = mAm.getRunningTasks(100); for (ActivityManager.RunningTaskInfo rti : taskList) { //找到当前应用的task,并启动task的栈顶activity,达到程序切换到前台 if (rti.topActivity.getPackageName().equals(getPackageName())) { mAm.moveTaskToFront(rti.id, 0); return; } } // pending intent跳回去 Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { LogUtil.e(TAG, "Catch android.app.PendingIntent.CanceledException: " + e.getMessage(), e); } } }
Example 18
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 19
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 20
Source File: LockPatternActivity.java From android-lockpattern with Apache License 2.0 | 4 votes |
/** * Finishes activity with {@link Activity#RESULT_OK}. * * @param pattern * the pattern, if this is in mode creating pattern. In any * cases, it can be set to {@code null}. */ private void finishWithResultOk(char[] pattern) { if (ACTION_CREATE_PATTERN.equals(getIntent().getAction())) mIntentResult.putExtra(EXTRA_PATTERN, pattern); else { /* * If the user was "logging in", minimum try count can not be zero. */ mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount + 1); } setResult(RESULT_OK, mIntentResult); /* * ResultReceiver */ ResultReceiver receiver = getIntent().getParcelableExtra( EXTRA_RESULT_RECEIVER); if (receiver != null) { Bundle bundle = new Bundle(); if (ACTION_CREATE_PATTERN.equals(getIntent().getAction())) bundle.putCharArray(EXTRA_PATTERN, pattern); else { /* * If the user was "logging in", minimum try count can not be * zero. */ bundle.putInt(EXTRA_RETRY_COUNT, mRetryCount + 1); } receiver.send(RESULT_OK, bundle); } /* * PendingIntent */ PendingIntent pi = getIntent().getParcelableExtra( EXTRA_PENDING_INTENT_OK); if (pi != null) { try { pi.send(this, RESULT_OK, mIntentResult); } catch (Throwable t) { Log.e(CLASSNAME, "Error sending PendingIntent: " + pi, t); } } finish(); }