如何利用kotlin语言实现调用系统的电话和短信功能呢,其实很简单,只要利用Intent()并且设置一下其action和data属性即可,action代表的就是行动,如打电话就是ACTION_DIAL,发短信就是ACTION_SENDTO,然后data就是设置一些特定的属性,如拨打的号码,短信的内容等。
先看布局文件代码
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
android:id="@+id/call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="打电话" />
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发短信" />
再看Activity里面onCreate()方法的