tags:

views:

93

answers:

1

Hello, I've been successfully testing my app which sends a text message to another phone number. The problem came when I sent this to a buddy that has the NEXUS ONE. I added a pending intent to sendTextMessage() and saw I'm hitting: RESULT_ERROR_GENERIC_FAILURE.

Any ideas?? Thanks,

Jonathan

A: 

Hi!!!

Mi problem is the same and how Jonathan Akers said, the RESULT_ERROR_GENERIC_FAILURE, is triggered by the sender mobile (Nexus One) to any other, so, nothing sms message is send use this mobile phone by programmatically mode without use intent sms messaging.

All works fine using two android emulators.

I use BroadcastReceiver for listen sms events like as: ` public class ConfigSMS {

private static final String CLASS_NAME = "smsTestClass";

private static PendingIntent sentPI         =       null;
private static PendingIntent deliverPI      =       null;



//---------------       Getters & Setters       --------------------------//
public static PendingIntent getSentPI() {
    if (sentPI == null)
        initPI();
    return sentPI;
}
public static void setSentPI(PendingIntent sentPI) {
    ConfigSMS.sentPI = sentPI;
}

public static PendingIntent getDeliverPI() {
    if (deliverPI == null)
        initPI();
    return deliverPI;
}
public static void setDeliverPI(PendingIntent deliverPI) {
    ConfigSMS.deliverPI = deliverPI;
}
//------------------------------------------------------------------------//


/**
 * Initialize the Intents and BroadcastReceivers
 */
public static void initPI () {

    monitoringSMS();
}


/**
 * Create the inits and BroadcastReceivers for listen sms actions
 */
private static void monitoringSMS () {

    try {
        final String SENT_SMS_ACTION            =   "SENT_SMS_ACTION";
        final String DELIVERED_SMS_ACTION       =   "DELIVERED_SMS_ACTION";

        //Create the setIntent parameter
        Intent sentIntent = new Intent(SENT_SMS_ACTION);
        sentPI = PendingIntent.getBroadcast(
                ConfigAppValues.getContext(),
                0,
                sentIntent,
                0);

        //Create the deliveryIntetn parameter
        Intent deliveryIntent = new Intent(DELIVERED_SMS_ACTION);
        deliverPI = PendingIntent.getBroadcast(
                ConfigAppValues.getContext(),
                0,
                deliveryIntent,
                0);

        //Register the Broadcast Receivers
        ConfigAppValues.getContext().registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {

                switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        Log.d(CLASS_NAME, "Successful transmission!!");
                        showNotificationToast("Successful transmission!!");
                        break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        Log.d(CLASS_NAME, "Nonspecific Failure!!");
                        showNotificationToast("Nonspecific Failure!!");
                        break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        Log.d(CLASS_NAME, "Radio is turned Off!!");
                        showNotificationToast("Nonspecific Failure!!");
                        break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        Log.d(CLASS_NAME, "PDU Failure");
                        showNotificationToast("PDU Failure");
                        break;
                }                   
            }
        }, new IntentFilter(SENT_SMS_ACTION));

        ConfigAppValues.getContext().registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                Log.d(CLASS_NAME, "The user have been receive the SMS message!!");

            }
        }, new IntentFilter(DELIVERED_SMS_ACTION));


    }catch (Exception e) {
        Log.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(
                e.toString(), 
                e.getStackTrace()));
    }
}

private static void showNotificationToast (String message) {

    try {

        //Show the toast message
        Toast.makeText(
                ConfigAppValues.getContext(),
                message,
                Toast.LENGTH_SHORT).show(); 

    }catch (Exception e) {
        Log.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
}

} `

And for send sms message i use this PendingInents how has been put at the application launch, my logs said that all was right except for this, that launch the RESULT_ERROR_GENERIC_FAILURE flag. The code is:`SmsManager smsManager = SmsManager.getDefault();

            Log.d(CLASS_NAME, "SmsText: " + smsText);
            //String test = "5556";
            smsManager.sendTextMessage(
                    receiver, 
                    null, 
                    smsText, 
                    ConfigSMS.getSentPI(), 
                    ConfigSMS.getDeliverPI());`

And that is all i don't have idea that is for my mobile phone or anything, how i said all works fine using two android emulators, Activity.RESULT_OK is launched and the sms message is received for the listen emulator.

Thanks for all!!

Cesar Valiente