Android打电话&发短信
16lz
2021-12-04
- publicvoidonCreate(BundlesavedInstanceState){
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- mobileEditText=(EditText)this.findViewById(R.id.app_name);
- mobileButton=(Button)this.findViewById(R.id.button);
- mobileButton.setOnClickListener(newView.OnClickListener(){
- @Override
- publicvoidonClick(Viewv){
- //TODOAuto-generatedmethodstub
- Stringmobile=mobileEditText.getText().toString();
- Intentintent=newIntent(Intent.ACTION_CALL,Uri.parse("tel:"+mobile));
- androidTest2Activity.this.startActivity(intent);
- }
- });
- }
- --------------------------------------------------------------------------------------
- publicvoidonClick(Viewv){
- //TODOAuto-generatedmethodstub
- Stringmobile=mobileText.getText().toString();
- Stringcontent=contentText.getText().toString();
- SmsManagersmsManager=SmsManager.getDefault();
- if(content.length()>70){
- List<String>contents=smsManager.divideMessage(content);
- for(Stringsms:contents){
- smsManager.sendTextMessage(mobile,null,sms,null,null);
- }
- }
- else{
- smsManager.sendTextMessage(mobile,null,content,null,null);
- }
- Toast.makeText(SMSActivity.this,"发送成功",2).show();
- }
本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/702527
更多相关文章
- Android(安卓)蓝牙(BLE)连接,发送,接收消息
- Android(安卓)短信发送器
- android studio 53 mp3
- Android库. 1 UDP客户端
- android发送短信
- android 中调用接口发送短信
- Android中短信的收发机制 发送短信 接收短信 拦截短信 监听短信
- 【Android】Android6.0发送短信Demo
- android - uri