Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 1차원 DP
- 2차원 dp
- 99클럽
- @BeforeAll
- @BeforeEach
- @Builder
- @Entity
- @GeneratedValue
- @GenericGenerator
- @NoargsConstructor
- @Query
- @Table
- @Transactional
- Actions
- Amazon EFS
- amazon fsx
- Android Studio
- ANSI SQL
- ApplicationEvent
- assertThat
- async/await
- AVG
- AWS
- Azure
- bind
- builder
- button
- c++
- c++ builder
- c03
Archives
- Today
- Total
기록
androidStudio/java/다른 앱으로 사용자 보내기 본문
manifests
해당 기능을 사용하는 activity에 intent 필터 추가
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="geo" />
</intent-filter>
</activity>
MainActivity.java
해당 activity에 함수 작성
카카오맵의 경우 "market://details?id=net.daum.android.map"
네이버맵의 경우 "market://details?id=com.nhn.android.nmap"
// 외부 지도어플 열기
public void openMap(Double latitude, Double longitude){
// Build the intent
Uri location = Uri.parse("geo:"+latitude+","+longitude);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
// 사용할 수 있는 어플이 있는지 확인
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(mapIntent, 0);
boolean isIntentSafe = activities.size() > 0;
// Start an activity if it's safe
if (isIntentSafe) {
startActivity(mapIntent);
}
// 어플이 없다면 app store, navermap 설치 화면으로 연결
else {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.nhn.android.nmap")));
}
}
실행결과
지도를 사용할 수 있는 어플을 검색하여 선택할 수 있음.
참고 사이트
https://developer.android.com/training/basics/intents/sending?hl=ko#java
'Moblie > Android' 카테고리의 다른 글
androidStudio/Google Map API 사용하기 (0) | 2021.11.28 |
---|---|
androidStudio/localhost 서버 접속하기 (0) | 2021.06.07 |
androidStudio/실제 단말기를 이용하여 실행시키기 (0) | 2021.03.12 |
[issue] Caused-by-javalangBootstrapMethodError-Exception-from-call-site-4-bootstrap-method (0) | 2020.09.29 |
androidStudio/java/preference:1.1.1 사용하기 (0) | 2020.09.29 |
Comments