반응형
//selectContact();
//openWebPage("https://m.naver.com");
//composeSMS("010-1234-5678", "안녕하세요", null);
//composeEmail(new String[]{"beautystar0413@gmail.com"}, "HelloWorld!");
// 주소록을 여는 메소드
void selectContact() {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
// 웹페이지를 여는 메소드
void openWebPage(String URL) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL));
startActivity(intent);
}
// 메시지 보내는 메소드
void composeSMS(String phoneNumber, String message, Uri attachment){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("smsTo:" + phoneNumber));
intent.putExtra("smsBody", message);
intent.putExtra(Intent.EXTRA_STREAM, attachment);
startActivity(intent);
}
// 이메일을 보내는 메소드
void composeEmail(String[] addresses, String subject) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
startActivity(intent);
}
반응형