Search in sources :

Example 1 with CanceledException

use of android.app.PendingIntent.CanceledException in project android_frameworks_base by ParanoidAndroid.

the class KeyguardTransportControlView 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();
    }
}
Also used : KeyEvent(android.view.KeyEvent) CanceledException(android.app.PendingIntent.CanceledException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 2 with CanceledException

use of android.app.PendingIntent.CanceledException in project android_frameworks_base by ParanoidAndroid.

the class AudioService method dispatchMediaKeyEvent.

/**
     * Handles the dispatching of the media button events to one of the registered listeners,
     * or if there was none, broadcast an ACTION_MEDIA_BUTTON intent to the rest of the system.
     * @param keyEvent a non-null KeyEvent whose key code is one of the supported media buttons
     * @param needWakeLock true if a PARTIAL_WAKE_LOCK needs to be held while this key event
     *     is dispatched.
     */
private void dispatchMediaKeyEvent(KeyEvent keyEvent, boolean needWakeLock) {
    if (needWakeLock) {
        mMediaEventWakeLock.acquire();
    }
    Intent keyIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null);
    keyIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
    synchronized (mRCStack) {
        if (!mRCStack.empty()) {
            // send the intent that was registered by the client
            try {
                mRCStack.peek().mMediaIntent.send(mContext, needWakeLock ? WAKELOCK_RELEASE_ON_FINISHED : 0, /*code*/
                keyIntent, AudioService.this, mAudioHandler);
            } catch (CanceledException e) {
                Log.e(TAG, "Error sending pending intent " + mRCStack.peek());
                e.printStackTrace();
            }
        } else {
            //    through AudioManager
            if (needWakeLock) {
                keyIntent.putExtra(EXTRA_WAKELOCK_ACQUIRED, WAKELOCK_RELEASE_ON_FINISHED);
            }
            final long ident = Binder.clearCallingIdentity();
            try {
                mContext.sendOrderedBroadcastAsUser(keyIntent, UserHandle.ALL, null, mKeyEventDone, mAudioHandler, Activity.RESULT_OK, null, null);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Example 3 with CanceledException

use of android.app.PendingIntent.CanceledException in project android_frameworks_base by ResurrectionRemix.

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) {
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 4 with CanceledException

use of android.app.PendingIntent.CanceledException in project android_frameworks_base by DirtyUnicorns.

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) {
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 5 with CanceledException

use of android.app.PendingIntent.CanceledException in project XobotOS by xamarin.

the class GsmSMSDispatcher method handleStatusReport.

/**
     * Called when a status report is received.  This should correspond to
     * a previously successful SEND.
     *
     * @param ar AsyncResult passed into the message handler.  ar.result should
     *           be a String representing the status report PDU, as ASCII hex.
     */
private void handleStatusReport(AsyncResult ar) {
    String pduString = (String) ar.result;
    SmsMessage sms = SmsMessage.newFromCDS(pduString);
    if (sms != null) {
        int tpStatus = sms.getStatus();
        int messageRef = sms.messageRef;
        for (int i = 0, count = deliveryPendingList.size(); i < count; i++) {
            SmsTracker tracker = deliveryPendingList.get(i);
            if (tracker.mMessageRef == messageRef) {
                // Found it.  Remove from list and broadcast.
                if (tpStatus >= Sms.STATUS_FAILED || tpStatus < Sms.STATUS_PENDING) {
                    deliveryPendingList.remove(i);
                }
                PendingIntent intent = tracker.mDeliveryIntent;
                Intent fillIn = new Intent();
                fillIn.putExtra("pdu", IccUtils.hexStringToBytes(pduString));
                fillIn.putExtra("format", android.telephony.SmsMessage.FORMAT_3GPP);
                try {
                    intent.send(mContext, Activity.RESULT_OK, fillIn);
                } catch (CanceledException ex) {
                }
                // Only expect to see one tracker matching this messageref
                break;
            }
        }
    }
    acknowledgeLastIncomingSms(true, Intents.RESULT_SMS_HANDLED, null);
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Aggregations

CanceledException (android.app.PendingIntent.CanceledException)33 PendingIntent (android.app.PendingIntent)26 Intent (android.content.Intent)25 AlertDialog (android.app.AlertDialog)3 Bundle (android.os.Bundle)3 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)3 SmsMessage (android.telephony.SmsMessage)3 KeyEvent (android.view.KeyEvent)3 SuppressLint (android.annotation.SuppressLint)2 Activity (android.app.Activity)2 AsyncResult (android.os.AsyncResult)2 RecognizerIntent (android.speech.RecognizerIntent)2 ArrayList (java.util.ArrayList)2 NonNull (android.annotation.NonNull)1 ActivityThread (android.app.ActivityThread)1 FLAG_CANCEL_CURRENT (android.app.PendingIntent.FLAG_CANCEL_CURRENT)1 FLAG_IMMUTABLE (android.app.PendingIntent.FLAG_IMMUTABLE)1 FLAG_NO_CREATE (android.app.PendingIntent.FLAG_NO_CREATE)1 FLAG_ONE_SHOT (android.app.PendingIntent.FLAG_ONE_SHOT)1 FLAG_UPDATE_CURRENT (android.app.PendingIntent.FLAG_UPDATE_CURRENT)1