开发者

SmsManager succes

I'm using the following code to send an sms. But this seems to not generate an exception when an sms is not send. For instance when there's not enough money left to send it, I still go to smsSucces(); Does anyone kow a way to solve this for knowing sure it has been sent?

    private boolean composeSms(String telefoonnr, String boodschap) {
    if(telef开发者_高级运维oonnr.equals("") || boodschap.equals(""))   {
        smsFail();
        return false;
    }
    try {
    SmsManager sm =  SmsManager.getDefault();
    //PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, SmsActivity.class), 0);   
    sm.sendTextMessage(telefoonnr, null, boodschap, null, null);
    DataClass dc = (DataClass) getApplicationContext();
    dc.setBoolean(DataClass.ACTIVATED_SMS, true);
    dc.setString(DataClass.SMS_NUMBER, telefoonnr);
    Log.d("temp","sms send succesfully");
    smsSucces();
    return true;
    }
    catch (Exception e) {
        e.printStackTrace();
        smsFail();
        return false;
    }


}


Hi you can use Broadcast for SMS delivery report `

Here is the code for this

// SMS delivered pending intent

PendingIntent deliveredIntent = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED_ACTION), 0);

// SMS sent receiver

registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "SMS sent intent received.");
}
}, new IntentFilter(SENT_ACTION));

// SMS delivered receiver

registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "SMS delivered intent received.");
}
}, new IntentFilter(DELIVERED_ACTION));


Not sure to be honest. But maybe you can find the answer here: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/os/SmsMessagingDemo.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜