eclipse 拨打电话、拨号,发短信
生活随笔
收集整理的這篇文章主要介紹了
eclipse 拨打电话、拨号,发短信
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.撥打電話,撥號
//撥打電話Intent intent = new Intent(); intent.setAction(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:"+phoneNumber)); startActivity(intent); //撥號
Intent intent = new Intent(); intent.setAction(intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + phoneNumber)); startActivity(intent);
注意:"tel:"一定要小寫!
需要配置android.permission.CALL_PHONE權限
2.發短信
android.telephony.SmsManager smsManager =android.telephony.SmsManager.getDefault(); //divide message into several messages. ArrayList<String> ary_sms = smsManager.divideMessage(str_content); for (String smss : ary_sms) {smsManager.sendTextMessage(str_phone, null, smss, null, null); } Toast.makeText(getApplicationContext(), R.string.msg_sendfinish, Toast.LENGTH_LONG).show();注意:需要配置android.permission.SEND_SMS權限
轉載于:https://www.cnblogs.com/jenney-qiu/p/3729133.html
總結
以上是生活随笔為你收集整理的eclipse 拨打电话、拨号,发短信的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 异常处理:try-catch-final
- 下一篇: 力扣算法题—074搜索二维矩阵