项目需求点击按钮,自动发送短信到特定的电话号码。写了一个简单demo,如下:
点击发送按钮时发送短信到特定号码,具体的代码如下:
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);paIntent = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
smsManager = SmsManager.getDefault();findViewById(R.id.sendButton).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
smsManager.sendTextMessage(&qu…………………………………………………………………………