android打电话和发短信
16lz
2021-01-23
打电话
先加入打电话的权限
<user-permission android:name="android.permission.CALL_PHONE"/>
创建Intent对象
Intent intent=new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:12312"));
startActivity(intent);
这样就可以了,你可以把这段代码写在按钮的点击事件中
发短信
先加入权限
<user-permission android:name="android.permission.SEND_SMS"/>
创建Intente对象
Intent intent=new Intent();
intent.setAction(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:12312"));
intent.putExtra("sms_body","hello");//注意这是发送短信时的默认写入的信息,sms_body是默认的不能改
startActivity(intent);
更多相关文章
- Android下获取Root权限和设置目录属性
- Android webview与js 交换JSON对象数据
- android 上 webkit js 扩展之全局本地对象实现步骤
- Android修改system只读权限:remount
- Android 无须获取Root权限静默安装App
- Android应用商店——Splash页面的实现,Android运行时权限的使用
- Android权限管理之Permission权限机制及使用
- android Parcelable接口序列化对象
- RK3326 Android 8.1 为自己的APK的服务默认开启无障碍权限,避免使