본문 바로가기

Daily Sample

[Day2] Intent 명령으로 웹뷰/전화번호부/다른창 호출하는 소스

TITLE : Simple Intent TEST
Date : 04/13/2010
Writen by Dayyoung
Description :
This is Source that Call the WebView, Adress-Book or OtherView by Intent method.
Intent 명령으로 웹뷰/주소록/다른화면 호출하는 소스
Download :  


인텐트 명령은 일반적으로 독립적으로 작동하는 액티비티간의 사용을 위해서 사용됨

액티비티 사용 명령어는 비동기식 startActivity 와 동기식인 startActivityForResult 가 있다.

1. 버튼3개로 구성된 기본화면


2. 특정 주소의 웹뷰 호출 (WebView와 유사하지만 전체크기로 가져옴)

Intent intent = new Intent (Intent.ACTION_VIEW,Uri.parse(“http://m.naver.com“));
startActivity(intent);



3. 특정넘버가 찍히는 전화번호부 호출

Intent intent = new Intent (Intent.ACTION_VIEW,Uri.parse(“tel:/010-0000-0000″));
startActivity(intent);


4. startActivity 명령어를 사용하여 또다른 Activity 활성화

Intent intent = new Intent (mainActivity.this,AnotherActivity.class);
//1. 일반적인 방법으로 다른 액티비티를 호출

Intent intent = new Intent (getApplicationContext(),AnotherActivity.class);
//2. 어플리케이션 컨텍스트(여기서는 mainActivity) 호출

Intent intent = new Intent (getBaseContext(),AnotherActivity.class);
//3 .베이스 컨텍스트(여기서는 mainActivity) 호출

Intent intent = new Intent (this.getContext(),AnotherActivity.class);
//4. 만약 현재액티비티가 아닌 현재액티비티에 달려있는 뷰(버튼/택스트뷰)에서 다른 액티비티를 가져올 경우

startActivity(intent);



Creative Commons License
이 저작물은 크리에이티브 커먼즈 저작자표시 3.0 Unported 라이선스에 따라 이용할 수 있습니다.