티스토리 뷰
[Android Studio] 간단하게 하이퍼링크 걸기 안드로이드 스튜디오
안드로이드 스튜디오에서 매우 간단하게 하이퍼링크를 거는 방법을 공유합니다.
우선 XML에 버튼 2개를 생성하겠습니다.
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="전화걸기"
android:id="@+id/btn_call"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="블로그 열기"
android:id="@+id/btn_threeidiotscoding"/>
이후 Java MainActivity 클래스에 코드 작성을 합니다.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn_call = findViewById(R.id.btn_call);
Button btn_threeidiotscoding = findViewById(R.id.btn_threeidiotscoding);
}
public void onClick(View v){
Intent intent = new Intent(Intent.ACTION_VIEW);
switch (v.getId()){
case R.id.btn_call:
intent.setData(Uri.parse("tel:010-1234-5678"));
startActivity(intent);
break;
case R.id.btn_threeidiotscoding:
intent.setData(Uri.parse("https://threeidiotscoding.tistory.com/"));
startActivity(intent);
break;
}
}
}
실행을 해보면 간단하게 하이퍼링크가 걸려있는 모습을 확인할 수 있습니다.

Intent를 이용한 간단한 하이퍼링크 걸기였습니다.
주의하실 점은 연락처 입력 시 앞쪽에 "tel:"을 필수로 붙여주셔야 합니다.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("URL"));
startActivity(intent);
'안드로이드 > JAVA' 카테고리의 다른 글
| [Android Studio] 간단하게 Fragment에서 getContentResolver() 사용하기 getApplicationContext() (0) | 2020.11.05 |
|---|---|
| [Android Studio] Glide를 이용한 FirebaseStorage 사진 불러오기, 이미지 가져오기 (0) | 2020.11.04 |
| [Android Studio] 안드로이드 스튜디오 시작페이지 메인엑티비티 변경하기 (0) | 2020.11.01 |
| [Android Studio] 간단하게 캡처금지하기, 캡쳐방지 하기 (0) | 2020.10.31 |
| [Android Studio] 간단하게 버튼 중복클릭 시간 제한하기 (0) | 2020.10.30 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 코틀린
- 안드로이드 스튜디오 해시키
- next.js useEffect
- react native oss
- gitlab mirror
- github mirror
- 깃허브 잔디 옮기기
- 깃랩에서 깃허브로
- 안드로이드 해시키
- amplify next.js
- amplify build error
- rn oss
- react native 오픈소스 라이선스
- next.js ssr deploy
- 깃허브에서 깃랩으로
- 안드로이드 스튜디오
- 깃랩 잔디 옮기기
- Android Studio
- Build failed because of webpack errors
- kotlin
- room error
- nextjs ssr deploy
- react.js useEffect
- 커밋 이메일 변경
- non-zero exit code detected
- 라이브러리 라이센스
- 카카오 해시키
- rn 오픈소스 라이센스
- next useEffect
- kakao api notworking
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
글 보관함
