use of android.app.PendingIntent.CanceledException in project XobotOS by xamarin.
the class SMSDispatcher method handleSendComplete.
/**
* Called when SMS send completes. Broadcasts a sentIntent on success.
* On failure, either sets up retries or broadcasts a sentIntent with
* the failure in the result code.
*
* @param ar AsyncResult passed into the message handler. ar.result should
* an SmsResponse instance if send was successful. ar.userObj
* should be an SmsTracker instance.
*/
protected void handleSendComplete(AsyncResult ar) {
SmsTracker tracker = (SmsTracker) ar.userObj;
PendingIntent sentIntent = tracker.mSentIntent;
if (ar.exception == null) {
if (false) {
Log.d(TAG, "SMS send complete. Broadcasting " + "intent: " + sentIntent);
}
if (tracker.mDeliveryIntent != null) {
// Expecting a status report. Add it to the list.
int messageRef = ((SmsResponse) ar.result).messageRef;
tracker.mMessageRef = messageRef;
deliveryPendingList.add(tracker);
}
if (sentIntent != null) {
try {
if (mRemainingMessages > -1) {
mRemainingMessages--;
}
if (mRemainingMessages == 0) {
Intent sendNext = new Intent();
sendNext.putExtra(SEND_NEXT_MSG_EXTRA, true);
sentIntent.send(mContext, Activity.RESULT_OK, sendNext);
} else {
sentIntent.send(Activity.RESULT_OK);
}
} catch (CanceledException ex) {
}
}
} else {
if (false) {
Log.d(TAG, "SMS send failed");
}
int ss = mPhone.getServiceState().getState();
if (ss != ServiceState.STATE_IN_SERVICE) {
handleNotInService(ss, tracker);
} else if ((((CommandException) (ar.exception)).getCommandError() == CommandException.Error.SMS_FAIL_RETRY) && tracker.mRetryCount < MAX_SEND_RETRIES) {
// Retry after a delay if needed.
// TODO: According to TS 23.040, 9.2.3.6, we should resend
// with the same TP-MR as the failed message, and
// TP-RD set to 1. However, we don't have a means of
// knowing the MR for the failed message (EF_SMSstatus
// may or may not have the MR corresponding to this
// message, depending on the failure). Also, in some
// implementations this retry is handled by the baseband.
tracker.mRetryCount++;
Message retryMsg = obtainMessage(EVENT_SEND_RETRY, tracker);
sendMessageDelayed(retryMsg, SEND_RETRY_DELAY);
} else if (tracker.mSentIntent != null) {
int error = RESULT_ERROR_GENERIC_FAILURE;
if (((CommandException) (ar.exception)).getCommandError() == CommandException.Error.FDN_CHECK_FAILURE) {
error = RESULT_ERROR_FDN_CHECK_FAILURE;
}
// Done retrying; return an error to the app.
try {
Intent fillIn = new Intent();
if (ar.result != null) {
fillIn.putExtra("errorCode", ((SmsResponse) ar.result).errorCode);
}
if (mRemainingMessages > -1) {
mRemainingMessages--;
}
if (mRemainingMessages == 0) {
fillIn.putExtra(SEND_NEXT_MSG_EXTRA, true);
}
tracker.mSentIntent.send(mContext, error, fillIn);
} catch (CanceledException ex) {
}
}
}
}
use of android.app.PendingIntent.CanceledException in project XobotOS by xamarin.
the class TransportControlView method sendMediaButtonClick.
private void sendMediaButtonClick(int keyCode) {
if (mClientIntent == null) {
// Shouldn't be possible because this view should be hidden in this case.
Log.e(TAG, "sendMediaButtonClick(): No client is currently registered");
return;
}
// use the registered PendingIntent that will be processed by the registered
// media button event receiver, which is the component of mClientIntent
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
mClientIntent.send(getContext(), 0, intent);
} catch (CanceledException e) {
Log.e(TAG, "Error sending intent for media button down: " + e);
e.printStackTrace();
}
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
mClientIntent.send(getContext(), 0, intent);
} catch (CanceledException e) {
Log.e(TAG, "Error sending intent for media button up: " + e);
e.printStackTrace();
}
}
use of android.app.PendingIntent.CanceledException in project robolectric by robolectric.
the class ShadowLocationManager method setProviderEnabled.
public void setProviderEnabled(String provider, boolean isEnabled, List<Criteria> criteria) {
LocationProviderEntry providerEntry = providersEnabled.get(provider);
if (providerEntry == null) {
providerEntry = new LocationProviderEntry();
}
providerEntry.enabled = isEnabled;
providerEntry.criteria = criteria;
providersEnabled.put(provider, providerEntry);
List<LocationListener> locationUpdateListeners = new ArrayList<>(getRequestLocationUpdateListeners());
for (LocationListener locationUpdateListener : locationUpdateListeners) {
if (isEnabled) {
locationUpdateListener.onProviderEnabled(provider);
} else {
locationUpdateListener.onProviderDisabled(provider);
}
}
// Send intent to notify about provider status
final Intent intent = new Intent();
intent.putExtra(LocationManager.KEY_PROVIDER_ENABLED, isEnabled);
ShadowApplication.getInstance().sendBroadcast(intent);
Set<PendingIntent> requestLocationUdpatePendingIntentSet = requestLocationUdpateCriteriaPendingIntents.keySet();
for (PendingIntent requestLocationUdpatePendingIntent : requestLocationUdpatePendingIntentSet) {
try {
requestLocationUdpatePendingIntent.send();
} catch (CanceledException e) {
requestLocationUdpateCriteriaPendingIntents.remove(requestLocationUdpatePendingIntent);
}
}
// if this provider gets disabled and it was the best active provider, then it's not anymore
if (provider.equals(bestEnabledProvider) && !isEnabled) {
bestEnabledProvider = null;
}
}
use of android.app.PendingIntent.CanceledException in project OneSignal-Android-SDK by OneSignal.
the class PushRegistratorGPS method ShowUpdateGPSDialog.
private void ShowUpdateGPSDialog() {
OSUtils.runOnMainUIThread(new Runnable() {
@Override
public void run() {
final Activity activity = ActivityLifecycleHandler.curActivity;
if (activity == null || OneSignal.mInitBuilder.mDisableGmsMissingPrompt)
return;
String alertBodyText = getResourceString(activity, "onesignal_gms_missing_alert_text", "To receive push notifications please press 'Update' to enable 'Google Play services'.");
String alertButtonUpdate = getResourceString(activity, "onesignal_gms_missing_alert_button_update", "Update");
String alertButtonSkip = getResourceString(activity, "onesignal_gms_missing_alert_button_skip", "Skip");
String alertButtonClose = getResourceString(activity, "onesignal_gms_missing_alert_button_close", "Close");
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(alertBodyText).setPositiveButton(alertButtonUpdate, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(appContext);
GooglePlayServicesUtil.getErrorPendingIntent(resultCode, activity, 0).send();
} catch (CanceledException e) {
} catch (Throwable e) {
e.printStackTrace();
}
}
}).setNegativeButton(alertButtonSkip, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final SharedPreferences prefs = OneSignal.getGcmPreferences(activity);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("GT_DO_NOT_SHOW_MISSING_GPS", true);
editor.commit();
}
}).setNeutralButton(alertButtonClose, null).create().show();
}
});
}
use of android.app.PendingIntent.CanceledException in project android_frameworks_base by crdroidandroid.
the class ImeTile method handleClick.
@Override
public void handleClick() {
mHost.collapsePanels();
Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
try {
pendingIntent.send();
} catch (CanceledException e) {
}
}
Aggregations