Video bài học:
Code gửi tin nhắn:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SENDTO);
intent.putExtra("sms:body", "nội dung tin nhắn...");
intent.setData(uri.parse("sms:09xxxxxxx"));
startActivity(intent);
Video bài học:
Code gọi điện thoại:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(uri.parse("tel:09xxxxxxx"));
startActivity(intent);
* Một lưu ý là:
Để ứng dụng có thể truy cập danh bạ và thực hiện cuộc gọi thì bạn phải code thêm 1 thẻ mainfest trong ứng dụng để ứng dụng có thể truy cập vào danh bạ của người dùng.
Làm như vậy nè:
-> truy cập app>>mainfest>>AndroidMainfest.xml. Thêm một thẻ mới
-> <uses-permission android:name="android.permission.CALL_PHONE"/>
Rồi vậy là xong!