Java Code Examples for android.app.PendingIntent#CanceledException
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: PendingIntentExecutor.java From Android-Scanner-Compat-Library with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onBatchScanResults(@NonNull final List<ScanResult> results) { final Context context = this.context != null ? this.context : this.service; if (context == null) return; // On several phones the broadcast is sent twice for every batch. // Skip the second call if came to early. final long now = SystemClock.elapsedRealtime(); if (lastBatchTimestamp > now - reportDelay + 5) { return; } lastBatchTimestamp = now; try { final Intent extrasIntent = new Intent(); extrasIntent.putExtra(BluetoothLeScannerCompat.EXTRA_CALLBACK_TYPE, ScanSettings.CALLBACK_TYPE_ALL_MATCHES); extrasIntent.putParcelableArrayListExtra(BluetoothLeScannerCompat.EXTRA_LIST_SCAN_RESULT, new ArrayList<Parcelable>(results)); extrasIntent.setExtrasClassLoader(ScanResult.class.getClassLoader()); callbackIntent.send(context, 0, extrasIntent); } catch (final PendingIntent.CanceledException e) { // Ignore } }
Example 2
Source File: MainActivity.java From arcgis-runtime-demos-android with Apache License 2.0 | 6 votes |
/** * Send an intent to start the geofence service that listens to location * updates at a normal rate of frequency. */ private void startGeofenceService() { LocalGeofence.setSubtitle(mFenceSubtitleEditText.getText().toString()); Intent serviceIntent = new Intent(MainActivity.ACTION_START_NORMAL_UPDATES, null, this, GeofenceServiceNormal.class); PendingIntent pendingIntent = PendingIntent.getService(this, 0, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT); try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { Toast.makeText(MainActivity.this, "Problem starting geofence service", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } }
Example 3
Source File: MD5_jni.java From stynico with MIT License | 6 votes |
/** 打开通知栏消息 */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 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 4
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 5
Source File: WeChatMsg.java From pc-android-controller-android with Apache License 2.0 | 6 votes |
public static void sendNotify(AccessibilityEvent event) { List<CharSequence> texts = event.getText(); if (!texts.isEmpty()) { String message = texts.get(0).toString(); //过滤微信内部通知消息 if (isInside(message)) { return; } //模拟打开通知栏消息 if (event.getParcelableData() != null && event.getParcelableData() instanceof Notification) { Log.i("demo", "标题栏canReply=true"); try { Notification notification = (Notification) event.getParcelableData(); PendingIntent pendingIntent = notification.contentIntent; pendingIntent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } } }
Example 6
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 7
Source File: OBStartUpBootReceiver.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
@Override public void onReceive (Context context, Intent intent) { try { PackageManager pm = context.getPackageManager(); Intent launchIntent = pm.getLaunchIntentForPackage(context.getPackageName()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, 0); // contentIntent.send(); // if (OBAnalyticsManager.sharedManager != null) { OBAnalyticsManager.sharedManager.deviceTurnedOn(); } } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } }
Example 8
Source File: AlarmManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void restorePendingWhileIdleAlarmsLocked() { if (RECORD_DEVICE_IDLE_ALARMS) { IdleDispatchEntry ent = new IdleDispatchEntry(); ent.uid = 0; ent.pkg = "FINISH IDLE"; ent.elapsedRealtime = SystemClock.elapsedRealtime(); mAllowWhileIdleDispatches.add(ent); } // Bring pending alarms back into the main list. if (mPendingWhileIdleAlarms.size() > 0) { ArrayList<Alarm> alarms = mPendingWhileIdleAlarms; mPendingWhileIdleAlarms = new ArrayList<>(); final long nowElapsed = SystemClock.elapsedRealtime(); for (int i=alarms.size() - 1; i >= 0; i--) { Alarm a = alarms.get(i); reAddAlarmLocked(a, nowElapsed, false); } } // Reschedule everything. rescheduleKernelAlarmsLocked(); updateNextAlarmClockLocked(); // And send a TIME_TICK right now, since it is important to get the UI updated. try { mTimeTickSender.send(); } catch (PendingIntent.CanceledException e) { } }
Example 9
Source File: NetworkUtils.java From SprintNBA with Apache License 2.0 | 5 votes |
/** * 强制帮用户打开GPS */ public static final void openGPS() { 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(AppUtils.getAppContext(), 0, GPSIntent, 0).send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } }
Example 10
Source File: ComplicationWatchFaceService.java From complications with Apache License 2.0 | 5 votes |
private void onComplicationTap(int complicationId) { // TODO: Step 5, onComplicationTap() Log.d(TAG, "onComplicationTap()"); ComplicationData complicationData = mActiveComplicationDataSparseArray.get(complicationId); if (complicationData != null) { if (complicationData.getTapAction() != null) { try { complicationData.getTapAction().send(); } catch (PendingIntent.CanceledException e) { Log.e(TAG, "onComplicationTap() tap action error: " + e); } } else if (complicationData.getType() == ComplicationData.TYPE_NO_PERMISSION) { // Watch face does not have permission to receive complication data, so launch // permission request. ComponentName componentName = new ComponentName( getApplicationContext(), ComplicationWatchFaceService.class); Intent permissionRequestIntent = ComplicationHelperActivity.createPermissionRequestHelperIntent( getApplicationContext(), componentName); startActivity(permissionRequestIntent); } } else { Log.d(TAG, "No PendingIntent for complication " + complicationId + "."); } }
Example 11
Source File: TutorialActivity.java From Pasta-Music with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { if(v.getId() == R.id.tutorial_button_left || v.getId() == R.id.tutorial_button_image_left) { boolean hasCustomAction = false; if(mFragmentList.get(mViewPager.getCurrentItem()) instanceof CustomAction) { if(((CustomAction)mFragmentList.get(mViewPager.getCurrentItem())).isEnabled()) { hasCustomAction = true; } } if(hasCustomAction) { PendingIntent intent = ((CustomAction)mFragmentList.get(mViewPager.getCurrentItem())).getCustomActionPendingIntent(); try { intent.send(); } catch (PendingIntent.CanceledException exception) { exception.printStackTrace(); } } else if(mViewPager.getCurrentItem() == 0) { finish(); } else { mViewPager.setCurrentItem(mViewPager.getCurrentItem()-1, true); } } else if (v.getId() == R.id.tutorial_button_image_right) { if(mViewPager.getCurrentItem() == getCount()-1) { finish(); } else { mViewPager.setCurrentItem(mViewPager.getCurrentItem()+1, true); } } }
Example 12
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 13
Source File: SampleMediaRouteProvider.java From V.FlyoutTest with MIT License | 5 votes |
private void handleSessionStatusChange(String sid) { if (mSessionReceiver != null) { Intent intent = new Intent(); intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, sid); intent.putExtra(MediaControlIntent.EXTRA_SESSION_STATUS, mSessionManager.getSessionStatus(sid).asBundle()); try { mSessionReceiver.send(getContext(), 0, intent); Log.d(TAG, mRouteId + ": Sending session status update from provider"); } catch (PendingIntent.CanceledException e) { Log.d(TAG, mRouteId + ": Failed to send session status update!"); } } }
Example 14
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 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: RedPacketService.java From styT with Apache License 2.0 | 5 votes |
/** * 开启红包所在的聊天页面 */ private void openWeChatPage(AccessibilityEvent event) { //A instanceof B 用来判断内存中实际对象A是不是B类型,常用于强制转换前的判断 if (event.getParcelableData() != null && event.getParcelableData() instanceof Notification) { Notification notification = (Notification) event.getParcelableData(); //打开对应的聊天界面 PendingIntent pendingIntent = notification.contentIntent; try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } }
Example 17
Source File: dex_smali.java From styT with Apache License 2.0 | 5 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 18
Source File: Utils.java From Mobike with Apache License 2.0 | 5 votes |
/** * 强制帮用户打开GPS * @param context */ public static final void openGPS(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 (PendingIntent.CanceledException e) { e.printStackTrace(); } }
Example 19
Source File: NotificationService.java From RelaxFinger with GNU General Public License v2.0 | 4 votes |
private void openNotification(int id) { StatusBarNotification sbn = mNotificationArray.get(id); if(sbn != null){ try { sbn.getNotification().contentIntent.send(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cancelNotification(sbn.getKey()); } cancelNotification(sbn.getPackageName(), sbn.getTag(), sbn.getId()); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } mNotificationArray.remove(id); }
Example 20
Source File: RCDevice.java From restcomm-android-sdk with GNU Affero General Public License v3.0 | 4 votes |
/** * Internal service callback; not meant for application use * @param jobId the job Id that was used in the original request, so that we can correlate the two * @param peer the peer from which the call arrived * @param sdpOffer sdp offer sent by the peer * @param customHeaders any custom SIP headers sent by the peer */ public void onCallArrivedEvent(String jobId, String peer, String sdpOffer, HashMap<String, String> customHeaders) { RCLogger.i(TAG, "onCallArrivedEvent(): id: " + jobId + ", peer: " + peer); // filter out potential '<' and '>' and leave just the SIP URI String peerSipUri = peer.replaceAll("^<", "").replaceAll(">$", ""); RCConnection connection = new RCConnection.Builder(true, RCConnection.ConnectionState.CONNECTING, this, signalingClient, audioManager) .jobId(jobId) .incomingCallSdp(sdpOffer) .peer(peerSipUri) .deviceAlreadyBusy(state == DeviceState.BUSY) .customHeaders(customHeaders) .build(); // keep connection in the connections hashmap connections.put(jobId, connection); if (state == DeviceState.BUSY) { // If we are already talking disconnect the new call connection.reject(); return; } state = DeviceState.BUSY; if (isAttached()) { audioManager.playRingingSound(); // Service is attached to an activity, let's send the intent normally that will open the call activity callIntent.setAction(ACTION_INCOMING_CALL); callIntent.putExtra(RCDevice.EXTRA_DID, peerSipUri); callIntent.putExtra(RCDevice.EXTRA_VIDEO_ENABLED, (connection.getRemoteMediaType() == RCConnection.ConnectionMediaType.AUDIO_VIDEO)); if (customHeaders != null) { callIntent.putExtra(RCDevice.EXTRA_CUSTOM_HEADERS, customHeaders); } //startActivity(callIntent); if (!this.parameters.containsKey(ParameterKeys.DEBUG_USE_BROADCASTS_FOR_EVENTS) || !(Boolean) this.parameters.get(ParameterKeys.DEBUG_USE_BROADCASTS_FOR_EVENTS)) { PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, callIntent, PendingIntent.FLAG_UPDATE_CURRENT); try { pendingIntent.send(); } catch (PendingIntent.CanceledException e) { throw new RuntimeException("Pending Intent cancelled", e); } } else { // ParameterKeys.DEBUG_USE_BROADCASTS_FOR_EVENTS == true, we need to broadcast a separate intent, so that the Test Case is able to receive it. // For some reason PendingIntent is not received properly even when we construct a broadcast for it using getBroadcast() Intent testIntent = new Intent(RCDevice.ACTION_INCOMING_CALL); //, null, InstrumentationRegistry.getTargetContext(), IntegrationTests.class)); testIntent.putExtra(RCDevice.EXTRA_DID, peerSipUri); sendBroadcast(testIntent); } // Phone state Intents to capture incoming phone call event sendQoSIncomingConnectionIntent(peerSipUri, connection); } else { onNotificationCall(connection, customHeaders); } }