728x90

안드로이드에서 Intent로 앱을 호출하는 방법 정리

 

연락처

연락처 조회

Intent intent = new Intent(Intent.ACTION_VIEW,
    Uri.parse("content://contacts/people/" + String.valueOf(contact.getId())));
startActivity(intent);

연락처 등록

Intent intent = new Intent(Intent.ACTION_INSERT,
    Uri.parse("content://contacts/people"));
startActivity(intent);

연락처 수정

Intent intent = new Intent(Intent.ACTION_EDIT,
    Uri.parse("content://contacts/people/" + String.valueOf(contact.getId())));
startActivity(intent);

연락처 삭제

Intent intent = new Intent(Intent.ACTION_DELETE,
    Uri.parse("content://contacts/people/" + String.valueOf(contact.getId())));
startActivity(intent);

 

전화

* 권한 설정 (AndroidManifest.xml)
전화 걸기 : CALL_PHONE = "android.permission.CALL_PHONE"
긴급 통화 : CALL_PRIVILEGED = "android.permission.CALL_PRIVILEGED"
폰 상태 읽기 : READ_PHONE_STATE = "android.permission.READ_PHONE_STATE"
폰 상태 수정 : MODIFY_PHONE_STATE = "android.permission.MODIFY_PHONE_STATE"
브로드케스팅 수신 : PROCESS_OUTGOING_CALLS = "android.permission.PROCESS_OUTGOING_CALLS"
전화 걸기 이전 : ACTION_NEW_OUTGOING_CALL = "android.intent.action.NEW_OUTGOING_CALL"

전화걸기 화면

Intent intent = new Intent(Intent.ACTION_DIAL,
    Uri.parse("tel:" + TelNumber));
startActivity(intent);

전화걸기

Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + TelNumber));
startActivity(intent);

 

SMS

* 권한 설정 (AndroidManifest.xml)
수신 모니터링 : RECEIVE_SMS = "android.permission.RECEIVE_SMS"
읽기 가능 : READ_SMS = "android.permission.READ_SMS"
발송 가능 : SEND_SMS = "android.permission.SEND_SMS"
SMS Provider로 전송 : WRITE_SMS = "android.permission.WRITE_SMS"
                            : BROADCAST_SMS = "android.permission.BROADCAST"

SMS 발송 화면

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("sms_body", "The SMS text");
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);

SMS 보내기

Intent intent = new Intent(Intent.ACTION_SENDTO,
    Uri.parse("smsto://01012341234"));
intent.putExtra("sms_body", "The SMS text");
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);

 

이메일

이메일 발송 화면

Intent intent = new Intent(Intent.ACTION_SENDTO,
    Uri.parse("mailto:" + contact.getEmail()));
startActivity(intent);

 

브라우저

Browser에서 URL 호출하기

Intent intent = new Intent(Intent.ACTION_VIEW,
    Uri.parse("http://www.google.com/"));
startActivity(intent);

브라우저에서 검색

Intent intent = new Intent(Intent.ACT ION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY, "검색어");
startActivity(intent);

 

지도

지도 보기

Uri uri = Uri.parse ("geo: 38.00, -35.03");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

 

안드로이드 마켓

안드로이드 마켓에서 Apps 검색

Uri uri = Uri.parse("market://search?q=pname:전제_패키지_명");  
//--- 예) market://search?q=pname:com.jopenbusiness.android.smartsearch
Intent intent = new Intent(Intent.ACTION_VIEW, uri);  
startActivity(intent); 

안드로이드 마켓의 App 상세 화면

Uri uri = Uri.parse("market://details?id=전제_패키지_명");
//--- 예) market://details?id=com.jopenbusiness.android.smartsearch
Intent intent = new Intent(Intent.ACTION_VIEW, uri);  
startActivity(intent);

 

설정화면

각 설정별 Activity Action : http://developer.android.com/reference/android/provider/Settings.html

 

* Activity Action 예시
WiFi : android.provider.Settings.ACTION_WIFI_SETTINGS
Bluetooth : android.provider.Settings.ACTION_BLUETOOTH_SETTINGS
디스플레이 : android.provider.Settings.ACTION_DISPLAY_SETTINGS

설정화면 부르기 (WiFi의 예)

Intent intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

 

728x90

+ Recent posts