Do you need RECEIVE_SMS permission to receive the deliveryIntent by any 
chance?

Here is my code - any help would be CRAZY appreciated =)
I always get the sent intent but never the delivery one.

            // The intent action to be unique so that we can have multiple
            // concurrent  pending intents.
            // 
http://developer.android.com/reference/android/app/PendingIntent.html
            String intentAction = TAG + "-" + callbackId;  // callbackId is 
unique per call
            Intent intent = new Intent(intentAction);

            PendingIntent sentPI = PendingIntent.getBroadcast(ctx, 0, 
intent, 0);

            cordova.getActivity().registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context ctx, Intent intent) {
                    int resultCode = getResultCode();
                    int status = -1;
                    String details = "";
                    switch (resultCode) {
                        case Activity.RESULT_OK:
                            status = 0;
                            break;
                        case SmsManager.RESULT_ERROR_NO_SERVICE:
                            details = "No service";
                        case SmsManager.RESULT_ERROR_NULL_PDU:
                            details = "Null PDU";
                        case SmsManager.RESULT_ERROR_RADIO_OFF:
                            details = "Radio off";
                            status = 1;
                            break;
                    }

                    JSONObject obj = new JSONObject();
                    try {
                        obj.put("status", status);
                        obj.put("details", details);
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                    sendAsyncResultStatus(callbackId, obj);
                    ctx.unregisterReceiver(this);
                }
            }, new IntentFilter(intentAction));

            // The intent action to be unique so that we can have multiple
            // concurrent  pending intents.
            // 
http://developer.android.com/reference/android/app/PendingIntent.html
            String deliveryIntentAction = TAG + "-Delivery-" + callbackId;
            Intent deliveryIntent = new Intent(deliveryIntentAction);

            PendingIntent deliveryPI = PendingIntent.getBroadcast(
                cordova.getActivity(), 0, deliveryIntent, 0);

            cordova.getActivity().registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context ctx, Intent intent) {
                    logger.log(Level.INFO, TAG + " DELIVERY intent YOYO!!");
                    String pdu = intent.getStringExtra("pdu");
                    logger.log(Level.INFO, TAG + " DELIVERY intent!! to: " +
                            sentToPhoneNumber + ", pdu: " + pdu);

                    JSONObject obj = new JSONObject();
                    try {
                        obj.put("pdu", pdu);
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                    sendAsyncResultStatus(callbackId, obj);
                    ctx.unregisterReceiver(this);
                }
            }, new IntentFilter(deliveryIntentAction));

            smsManager.sendTextMessage(phoneNumber, null, message, sentPI, 
deliveryPI);

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to