开发者

android send sms, why this will fail?

To send SMS I wrote below code:

package com.sendsms;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SendsmsActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button new_btn = (Button)findViewById(R.id.send_btn);
        new_btn.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v) {
                SmsManager sms = SmsManager.getDefault();
      开发者_开发百科          sms.sendTextMessage("+8615959762862", null, "i love you", null, null);    
            }
        });
    }
}

The stack:

ISms$Stub$Proxy.sendText(String, String, String, PendingIntent, PendingIntent) line: 443    
SmsManager.sendTextMessage(String, String, String, PendingIntent, PendingIntent) line: 87   
SendsmsActivity$1.onClick(View) line: 23    
Button(View).performClick() line: 2408  


Make Sure you Declare

<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>

In your Manifest

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜