一,电话拨号器的实现
权限
<uses-permission android:name="android.permission.CALL_PHONE"/>
java代码:
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ editText.getText())); DialerAction.this.startActivity(intent);
二,发送短信的实现
权限
<uses-permission android:name="android.permission.SEND_SMS"/>
Activity主要代码:
String mobile = mobileView.getText().toString(); String content = contentView.getText().toString(); SmsManager smsManager = SmsManager.getDefault(); PendingIntent sentIntent = PendingIntent.getBroadcast(context, 0, new Intent(), 0); if(content.length()>70){//如果字数超过70,需拆分成多条短信发送 List<String> msgs = smsManager.divideMessage(content); for(String msg : msgs){ smsManager.sendTextMessage(mobile, null, msg, sentIntent, null); //最后二个参数为短信已发送的广播意图,最后一个参数为短信对方已收到短信的广播意图 } }else{ smsManager.sendTextMessage(mobile, null, content, sentIntent, null); } Toast.makeText(SMSSender.this, "短信发送完成", Toast.LENGTH_LONG).show();