andriod学习—基于Android的拨号和SMS

来源:互联网 发布:photoshop cs6 mac 编辑:程序博客网 时间:2024/05/22 14:13

拨号

EditText editText=(EditText)findViewById(R.id.mobile);String mobile=editText.getText().toString(); //得到手机号Intent intent=new Intent("android.intent.action.CALL",Uri.parse("tel:"+mobile));

短信
String phoneNumber=((EditText)findViewById(R.id.edit_num)).getText().toString();
String content=((EditText)findViewById(R.id.content)).getText().toString();
//得到默认的短信管理器
SmsManager smsManager=SmsManager.getDefault();
//这里对输入的内容进行拆分,短信长度是有限制的
ArrayList<String> texts=smsManager.divideMessage(content);
//
for (String text : texts) {
//使用短信管理发送短信
smsManager.sendTextMessage(phoneNumber, null, text, null, null);
}
Toast.makeText(SMSActivity.this, “发送完成”, Toast.LENGTH_SHORT).show();

相应的权限声明  :

<uses-permission android:name=”android.permission.CALL_PHONE” />

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