SlideShare une entreprise Scribd logo
1  sur  19
크로스플랫폼 앱개발을 위한
자마린 기초강좌
Xamarin.Android 심플예제
현재 위치를 얻은 후 지도에 표시하기, 마시멜로
이후 권한 획득방법 구현
탑크리에듀(http://topcredu.co.kr), 이종철
예제 개요 – 프로젝트 생성
 Android 개발자가 이용할 수있는 130 가지 이상의 고유 권한을 사용하여 응용프로그램에
서 사용할 권한을 정확히 알기 어렵다. Android Marshmallow는 사용 권한을 단순화 할뿐
만 아니라 필요한 사용 권한의 수를 줄이기 위해 응용 프로그램 사용 권한에 대해 완전히
새로운 방향을 제시하는 데 예제를 통해 알아보자.
 폰접근 권한을 받아오고 GPS를 통해 위치 정보를 받아, 지도를 로딩하는 방법에 대한 실
습
 “GetLocation“ 라는 이름의 Xamarin.Android 프로젝트 생성
 AssemblyInfo.cs에 위치정보 서비스를 위한 두개의 권한을 허용
 사용자 위치를 얻기 위해 GPS를 사용해야하는 경우 ACCESS_FINE_LOCATION 및
ACCESS_COARSE_LOCATION 권한을 지정하고 API 레벨 23(마시멜로) 이상에서 런타임시
사용자에게 요청하게 된다.
탑크리에듀(http://topcredu.co.kr), 이종철
예제 개요 - 권한
 Android 애플리케이션에서 특정 API를 호출 할 때 필요한 모든 권한을 지정해야 한다. 즉,
사용자 위치를 얻기 위해 GPS를 사용해야하는 경우 ACCESS_FINE_LOCATION 및
ACCESS_COARSE_LOCATION 권한을 지정해야 했다. 사용 권한 그룹은 위치, 연락처, 전화,
센서, SMS 및 저장소와 같은 유사한 작업을 수행하는 사용 권한을 단순화하려고 시도하는
데 앱 그룹은 현재 1 ~ 7 개의 권한을 단일 권한 그룹으로 묶는데 한 번에 그룹의 모든 권
한을 요청할 수 있다.
 이러한 권한 그룹 중 하나에서 찾은 권한 또는 일반으로 지정되지 않은 권한을 사용하는
경우 사용자에게 권한을 요청해야 한다.
 Geolocator Plugin은 AccessFineLocation and AccessCoarseLocation 위치 권한을 모두
필요로하며, android.permission-group.LOCATION에 그룹화되어 있다.
AndroidManifest.xml에 이 두 가지 권한을 추가해야 하며 런타임에 요청해야 한다.
 [assembly: UsesPermission(Manifest.Permission.AccessFineLocation)]
 [assembly: UsesPermission(Manifest.Permission.AccessCoarseLocation)]
탑크리에듀(http://topcredu.co.kr), 이종철
예제 개요 - 권한
 AssemblyInfo.cs에 Geocoder 클래스를 사용하는 데 필요한 권한을 선언, 기기의 GPS 좌
표를 얻기 위해 꼭 필요한 것은 아니지만 본 예제에서는 현재 위치의 번지를 얻기 위해 사
용.[assembly: UsesPermission(Manifest.Permission.Internet)]
 위3가지 권한을 Properties 더블클릭 후 Android 매니페스트에서 필수권한을 체크하자.
탑크리에듀(http://topcredu.co.kr), 이종철
텍스트뷰와 버튼을 위한 UI 생성,
ResourcelayoutMain.axml
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
xmlns:android="http://schemas.android.com/ap
k/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:paddingTop="20dp"
 android:paddingLeft="8dp"
 android:paddingRight="8dp"
 android:id="@+id/main_layout">
탑크리에듀(http://topcredu.co.kr), 이종철
 <Button
 android:layout_width="fill_parent"

android:textAppearance="?android:attr/textA
ppearanceMedium"
 android:layout_height="wrap_content"

android:id="@+id/get_permission_button"
 android:text="Get Permission" />
텍스트뷰와 버튼을 위한 UI 생성,
ResourcelayoutMain.axml
 <Button
 android:layout_width="fill_parent"

android:textAppearance="?android:attr/textA
ppearanceMedium"
 android:layout_height="wrap_content"
 android:id="@+id/get_address_button"
 android:text="Get Location" />
탑크리에듀(http://topcredu.co.kr), 이종철
 <TextView
 android:layout_width="fill_parent"

android:textAppearance="?android:attr/textA
ppearanceMedium"
 android:layout_height="wrap_content"
 android:text="Location (when available)"
 android:id="@+id/location_text"
 android:layout_marginBottom="15dp"
/>
텍스트뷰와 버튼을 위한 UI 생성,
ResourcelayoutMain.axml
 <TextView
 android:layout_width="fill_parent"

android:textAppearance="?android:attr/textA
ppearanceMedium"
 android:layout_height="wrap_content"
 android:text="Address (when available)"
 android:id="@+id/address_text"
 android:layout_marginTop="10dp" />
탑크리에듀(http://topcredu.co.kr), 이종철
 <Button
 android:layout_width="fill_parent"

android:textAppearance="?android:attr/textA
ppearanceMedium"
 android:layout_height="wrap_content"
 android:id="@+id/get_map_button"
 android:text="Get Map" />
 </LinearLayout>
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using Android.App;
 using Android.Locations;
 using Android.OS;
 using Android.Util;
 using Android.Widget;
 using Android;
 using Android.Content.PM;
 using Android.Views;
 using Android.Content;
탑크리에듀(http://topcredu.co.kr), 이종철
 namespace GetLocation
 {

 [Activity(Label = "Get Location", MainLauncher =
true, Icon = "@drawable/icon")]
 public class MainActivity : Activity
 {
 static readonly string TAG = "[LOCATION APP]"
+ typeof(MainActivity).Name;
 TextView addressText;
 Location currentLocation;
 LocationManager locationManager = null;
 View layout;
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 string locationProvider;
 TextView locationText;

 const int RequestLocationId = 0;
 readonly string[] PermissionsLocation =
 {

Manifest.Permission.AccessCoarseLocation,

Manifest.Permission.AccessFineLocation
 };
탑크리에듀(http://topcredu.co.kr), 이종철
 protected override void OnCreate(Bundle bundle)
 {
 base.OnCreate(bundle);
 SetContentView(Resource.Layout.Main);

 addressText =
FindViewById<TextView>(Resource.Id.address_text);
 locationText =
FindViewById<TextView>(Resource.Id.location_text);
 layout =
FindViewById<LinearLayout>(Resource.Id.main_layo
ut);
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 Button permission_button =
FindViewById<Button>(Resource.Id.get_per
mission_button);
 permission_button.Click +=
PermissionButton_OnClick;

 Button addr_button =
FindViewById<Button>(Resource.Id.get_ad
dress_button);
 addr_button.Click +=
AddressButton_OnClick;
탑크리에듀(http://topcredu.co.kr), 이종철
 Button map_button =
FindViewById<Button>(Resource.Id.get_map
_button);
 map_button.Click +=
MapButton_OnClick;

 }
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 // 권한을 가져온다.
 void PermissionButton_OnClick(object
sender, EventArgs e)
 {
 if ((int)Build.VERSION.SdkInt < 23)
 {
 return;
 }
탑크리에듀(http://topcredu.co.kr), 이종철
 //Check to see if any permission in our group is
available, if one, then all are
 const string permission =
Manifest.Permission.AccessFineLocation;
 if (CheckSelfPermission(permission) ==
(int)Permission.Granted)
 {
 return;
 }

 //Finally request permissions with the list of
permissions and Id
 RequestPermissions(PermissionsLocation,
RequestLocationId);
 }
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 // 사용자가 권한 요청을 승인하거나 거부
한 후에는 응답을 처리하고 기능을 켜거나
끔
 // 권한이 요청 된 활동의
OnRequestPermissionsResult를 재정 의하여
수행
 // 이 메소드는 결과 코드 (권한을
요청할 때 지정된 코드)와 부여 또는 거부 된
결과를 리턴
 public override async void
OnRequestPermissionsResult(int
requestCode, string[] permissions,
Permission[] grantResults)
 { 탑크리에듀(http://topcredu.co.kr), 이종철
 switch (requestCode)
 {
 case RequestLocationId:
 {
 if (grantResults[0] == Permission.Granted)
 {
 var callDialog = new AlertDialog.Builder(this);
 callDialog.SetMessage("Permission Confirmed!
");
 callDialog.SetNeutralButton("OK",
 delegate
 {
 // Create intent to dial phone
 });
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 callDialog.Show();
 return;
 }
 else
 {
 var callDialog = new
AlertDialog.Builder(this);

callDialog.SetMessage("Permission Denied!
");
탑크리에듀(http://topcredu.co.kr), 이종철
 callDialog.SetNeutralButton("OK",
 delegate
 {
 // Create intent to
dial phone
 });
 callDialog.Show();
 return;
 }
 }
 }
 }
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 // 지도를 표시한다.
 async void MapButton_OnClick(object
sender, EventArgs e)
 {

 if (currentLocation == null)
 {
 addressText.Text = "Can't determine
the current address. Try again in a few
minutes.";
 return;
 }
탑크리에듀(http://topcredu.co.kr), 이종철
 Address address = await
ReverseGeocodeCurrentLocation();

 var geoUri =
Android.Net.Uri.Parse("geo:" +
address.Latitude.ToString()+",
"+address.Longitude.ToString());
 var mapIntent = new
Intent(Intent.ActionView, geoUri);
 StartActivity(mapIntent);
 }
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 // 위도와 경도를 읽고 에서 주소를 가져옴.
 async void
AddressButton_OnClick(object sender,
EventArgs e)
 {

 InitializeLocationManager();

 currentLocation =
locationManager.GetLastKnownLocation(loc
ationProvider);
탑크리에듀(http://topcredu.co.kr), 이종철
 if (currentLocation == null) {
 addressText.Text = "Can't determine the
current address. Try again in a few minutes.";
 return;
 }
 locationText.Text = string.Format("{0:f6},{1:f6}",
currentLocation.Latitude, currentLocation.Longitude);
 Address address = await
ReverseGeocodeCurrentLocation();
 DisplayAddress(address);
 }
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 // LocationManager 클래스는 장치에서 GPS 업데이트를
수신하고
 // 이벤트를 통해 응용 프로그램에 알린다.
 // 주어진 기준 세트와 일치하는 최고의 GPS 위치
제공자를 Android에 요청하고
 // 그 제공자를 LocationManager에 제공한다.
 void InitializeLocationManager()
 {
 locationManager =
(LocationManager)GetSystemService(LocationService);
 Criteria criteriaForLocationService = new Criteria
 {
 Accuracy = Accuracy.Fine
 };
탑크리에듀(http://topcredu.co.kr), 이종철
 IList<string> acceptableLocationProviders =
locationManager.GetProviders(criteriaForLoc
ationService, true);

 if (acceptableLocationProviders.Any())
 {
 locationProvider =
acceptableLocationProviders.First();
 }
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 else
 {
 locationProvider = string.Empty;
 }
 Log.Debug(TAG, "Using " +
locationProvider + ".");
 }
탑크리에듀(http://topcredu.co.kr), 이종철
 // 현재 위치의 Address 개체 컬렉션을 비동기 적으로
조회한다.
 // 위치 및 네트워크 가용성과 같은 요소에 따라
하나 또는 여러 개의 주소가 리턴되는데
 // 첫 번째 주소 (가능한 경우)는 Activity에
주소를 표시하는 DisplayAddress 메소드로 전달된다.
 async Task<Address>
ReverseGeocodeCurrentLocation()
 {
 Geocoder geocoder = new Geocoder(this);
 IList<Address> addressList =
 await
geocoder.GetFromLocationAsync(currentLocation.Lat
itude, currentLocation.Longitude, 10);
MainActivity.cs 파일에
Button의 클릭 이벤트 코드 작성
 Address address =
addressList.FirstOrDefault();
 return address;
 }
탑크리에듀(http://topcredu.co.kr), 이종철
 void DisplayAddress(Address address) {
 if (address != null) {
 StringBuilder deviceAddress = new
StringBuilder();

deviceAddress.AppendLine(address.GetAddressLine(0));
 // Remove the last comma from the end of the address.
 addressText.Text = deviceAddress.ToString();
 } else {
 addressText.Text = "Unable to determine the
address. Try again in a few minutes.";
 } } }}
실행 결과
탑크리에듀(http://topcredu.co.kr), 이종철

Contenu connexe

Similaire à (자마린안드로이드예제실습)현재 위치를 얻은 후 지도에 표시하기, GPS다루기, 마시멜로이후 권한 획득방법 구현_추천자마린학원/자마린교육

구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
구글 기술을 이용한 모바일 클라우드 애플리케이션 개발LGU+
 
Startup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JSStartup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JSCirculus
 
Vue.js 기초 실습.pptx
Vue.js 기초 실습.pptxVue.js 기초 실습.pptx
Vue.js 기초 실습.pptxwonyong hwang
 
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)LanarkSeung
 
20140122 techdays mini 앱 개발 세미나(3) - 센서활용 앱 개발
20140122 techdays mini  앱 개발 세미나(3) - 센서활용 앱 개발20140122 techdays mini  앱 개발 세미나(3) - 센서활용 앱 개발
20140122 techdays mini 앱 개발 세미나(3) - 센서활용 앱 개발영욱 김
 
안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서
안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서
안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서Chansuk Yang
 
챗봇 시작해보기
챗봇 시작해보기챗봇 시작해보기
챗봇 시작해보기성일 한
 
C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌
C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌
C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌탑크리에듀(구로디지털단지역3번출구 2분거리)
 
반복적인 작업이 싫은 안드로이드 개발자에게
반복적인 작업이 싫은 안드로이드 개발자에게반복적인 작업이 싫은 안드로이드 개발자에게
반복적인 작업이 싫은 안드로이드 개발자에게Sungju Jin
 
Node.js and react
Node.js and reactNode.js and react
Node.js and reactHyungKuIm
 
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]WSConf.
 
2019 Naver Tech Concert Android - Camera2
2019 Naver Tech Concert Android - Camera22019 Naver Tech Concert Android - Camera2
2019 Naver Tech Concert Android - Camera2SooHwan Ok
 
Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)fefe7270
 
[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발NAVER D2
 
[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라
[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라
[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라NAVER Engineering
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우Arawn Park
 

Similaire à (자마린안드로이드예제실습)현재 위치를 얻은 후 지도에 표시하기, GPS다루기, 마시멜로이후 권한 획득방법 구현_추천자마린학원/자마린교육 (20)

구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발 구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
구글 기술을 이용한 모바일 클라우드 애플리케이션 개발
 
Designing Apps for Motorla Xoom Tablet
Designing Apps for Motorla Xoom TabletDesigning Apps for Motorla Xoom Tablet
Designing Apps for Motorla Xoom Tablet
 
Startup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JSStartup JavaScript 8 - NPM, Express.JS
Startup JavaScript 8 - NPM, Express.JS
 
Vue.js 기초 실습.pptx
Vue.js 기초 실습.pptxVue.js 기초 실습.pptx
Vue.js 기초 실습.pptx
 
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
 
20140122 techdays mini 앱 개발 세미나(3) - 센서활용 앱 개발
20140122 techdays mini  앱 개발 세미나(3) - 센서활용 앱 개발20140122 techdays mini  앱 개발 세미나(3) - 센서활용 앱 개발
20140122 techdays mini 앱 개발 세미나(3) - 센서활용 앱 개발
 
안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서
안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서
안드로이드 6.0 마시멜로 지원을 고민하는 개발자를 위한 안내서
 
Nodejs express
Nodejs expressNodejs express
Nodejs express
 
Spring boot actuator
Spring boot   actuatorSpring boot   actuator
Spring boot actuator
 
챗봇 시작해보기
챗봇 시작해보기챗봇 시작해보기
챗봇 시작해보기
 
C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌
C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌
C#,자마린실습(Hello 안드로이드,이뮬레이터와 휴대폰에서 직접실행)_닷넷기초/C#기초/자마린,Xamarin 앱개발강좌
 
반복적인 작업이 싫은 안드로이드 개발자에게
반복적인 작업이 싫은 안드로이드 개발자에게반복적인 작업이 싫은 안드로이드 개발자에게
반복적인 작업이 싫은 안드로이드 개발자에게
 
Node.js and react
Node.js and reactNode.js and react
Node.js and react
 
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
 
Nest js 101
Nest js 101Nest js 101
Nest js 101
 
2019 Naver Tech Concert Android - Camera2
2019 Naver Tech Concert Android - Camera22019 Naver Tech Concert Android - Camera2
2019 Naver Tech Concert Android - Camera2
 
Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)
 
[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발[1A5]효율적인안드로이드앱개발
[1A5]효율적인안드로이드앱개발
 
[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라
[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라
[TECHCON 2019: MOBILE - Android]6.예제로 배우는 안드로이드 카메라
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우
 

Plus de 탑크리에듀(구로디지털단지역3번출구 2분거리)

[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)
[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)
[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)탑크리에듀(구로디지털단지역3번출구 2분거리)
 
(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...
(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...
(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...
[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...
[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...
C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...
C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]
자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]
자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]탑크리에듀(구로디지털단지역3번출구 2분거리)
 
3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]
3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]
3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]탑크리에듀(구로디지털단지역3번출구 2분거리)
 

Plus de 탑크리에듀(구로디지털단지역3번출구 2분거리) (20)

자마린.안드로이드 기본 내장레이아웃(Built-In List Item Layouts)
자마린.안드로이드 기본 내장레이아웃(Built-In List Item Layouts)자마린.안드로이드 기본 내장레이아웃(Built-In List Item Layouts)
자마린.안드로이드 기본 내장레이아웃(Built-In List Item Layouts)
 
(스프링프레임워크 강좌)스프링부트개요 및 HelloWorld 따라하기
(스프링프레임워크 강좌)스프링부트개요 및 HelloWorld 따라하기(스프링프레임워크 강좌)스프링부트개요 및 HelloWorld 따라하기
(스프링프레임워크 강좌)스프링부트개요 및 HelloWorld 따라하기
 
자마린 iOS 멀티화면 컨트롤러_네비게이션 컨트롤러, 루트 뷰 컨트롤러
자마린 iOS 멀티화면 컨트롤러_네비게이션 컨트롤러, 루트 뷰 컨트롤러자마린 iOS 멀티화면 컨트롤러_네비게이션 컨트롤러, 루트 뷰 컨트롤러
자마린 iOS 멀티화면 컨트롤러_네비게이션 컨트롤러, 루트 뷰 컨트롤러
 
[IT교육/IT학원]Develope를 위한 IT실무교육
[IT교육/IT학원]Develope를 위한 IT실무교육[IT교육/IT학원]Develope를 위한 IT실무교육
[IT교육/IT학원]Develope를 위한 IT실무교육
 
[아이오닉학원]아이오닉 하이브리드 앱 개발 과정(아이오닉2로 동적 모바일 앱 만들기)
[아이오닉학원]아이오닉 하이브리드 앱 개발 과정(아이오닉2로 동적 모바일 앱 만들기)[아이오닉학원]아이오닉 하이브리드 앱 개발 과정(아이오닉2로 동적 모바일 앱 만들기)
[아이오닉학원]아이오닉 하이브리드 앱 개발 과정(아이오닉2로 동적 모바일 앱 만들기)
 
[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)
[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)
[뷰제이에스학원]뷰제이에스(Vue.js) 프로그래밍 입문(프로그레시브 자바스크립트 프레임워크)
 
[씨샵학원/씨샵교육]C#, 윈폼, 네트워크, ado.net 실무프로젝트 과정
[씨샵학원/씨샵교육]C#, 윈폼, 네트워크, ado.net 실무프로젝트 과정[씨샵학원/씨샵교육]C#, 윈폼, 네트워크, ado.net 실무프로젝트 과정
[씨샵학원/씨샵교육]C#, 윈폼, 네트워크, ado.net 실무프로젝트 과정
 
[정보처리기사자격증학원]정보처리기사 취득 양성과정(국비무료 자격증과정)
[정보처리기사자격증학원]정보처리기사 취득 양성과정(국비무료 자격증과정)[정보처리기사자격증학원]정보처리기사 취득 양성과정(국비무료 자격증과정)
[정보처리기사자격증학원]정보처리기사 취득 양성과정(국비무료 자격증과정)
 
[wpf학원,wpf교육]닷넷, c#기반 wpf 프로그래밍 인터페이스구현 재직자 향상과정
[wpf학원,wpf교육]닷넷, c#기반 wpf 프로그래밍 인터페이스구현 재직자 향상과정[wpf학원,wpf교육]닷넷, c#기반 wpf 프로그래밍 인터페이스구현 재직자 향상과정
[wpf학원,wpf교육]닷넷, c#기반 wpf 프로그래밍 인터페이스구현 재직자 향상과정
 
(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...
(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...
(WPF교육)ListBox와 Linq 쿼리를 이용한 간단한 데이터바인딩, 새창 띄우기, 이벤트 및 델리게이트를 통한 메인윈도우의 ListB...
 
[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...
[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...
[자마린교육/자마린실습]자바,스프링프레임워크(스프링부트) RESTful 웹서비스 구현 실습,자마린에서 스프링 웹서비스를 호출하고 응답 JS...
 
[구로자마린학원/자마린강좌/자마린교육]3. xamarin.ios 3.3.5 추가적인 사항
[구로자마린학원/자마린강좌/자마린교육]3. xamarin.ios  3.3.5 추가적인 사항[구로자마린학원/자마린강좌/자마린교육]3. xamarin.ios  3.3.5 추가적인 사항
[구로자마린학원/자마린강좌/자마린교육]3. xamarin.ios 3.3.5 추가적인 사항
 
3. xamarin.i os 3.3 xamarin.ios helloworld 자세히 살펴보기 3.4.4 view controllers an...
3. xamarin.i os 3.3 xamarin.ios helloworld 자세히 살펴보기 3.4.4 view controllers an...3. xamarin.i os 3.3 xamarin.ios helloworld 자세히 살펴보기 3.4.4 view controllers an...
3. xamarin.i os 3.3 xamarin.ios helloworld 자세히 살펴보기 3.4.4 view controllers an...
 
5. 서브 쿼리(sub query) 5.1 서브 쿼리(sub query) 개요 5.2 단일행 서브쿼리(single row sub query)
5. 서브 쿼리(sub query) 5.1 서브 쿼리(sub query) 개요 5.2 단일행 서브쿼리(single row sub query)5. 서브 쿼리(sub query) 5.1 서브 쿼리(sub query) 개요 5.2 단일행 서브쿼리(single row sub query)
5. 서브 쿼리(sub query) 5.1 서브 쿼리(sub query) 개요 5.2 단일행 서브쿼리(single row sub query)
 
3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld(단일 뷰) 실습[...
3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld(단일 뷰) 실습[...3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld(단일 뷰) 실습[...
3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld(단일 뷰) 실습[...
 
(닷넷,자마린,아이폰실습)Xamarin.iOS HelloWorld 실습_멀티화면,화면전환_Xamarin교육/Xamarin강좌
(닷넷,자마린,아이폰실습)Xamarin.iOS HelloWorld 실습_멀티화면,화면전환_Xamarin교육/Xamarin강좌(닷넷,자마린,아이폰실습)Xamarin.iOS HelloWorld 실습_멀티화면,화면전환_Xamarin교육/Xamarin강좌
(닷넷,자마린,아이폰실습)Xamarin.iOS HelloWorld 실습_멀티화면,화면전환_Xamarin교육/Xamarin강좌
 
C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...
C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...
C#기초에서 윈도우, 스마트폰 앱개발 과정(c#.net, ado.net, win form, wpf, 자마린)_자마린학원_씨샵교육_WPF학원...
 
자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]
자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]
자바, 웹 기초와 스프링 프레임워크 & 마이바티스 재직자 향상과정(자바학원/자바교육/자바기업출강]
 
3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld_자마린학원_자마린...
3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld_자마린학원_자마린...3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld_자마린학원_자마린...
3. xamarin.i os 3.1 xamarin.ios 설치, 개발환경 3.2 xamarin.ios helloworld_자마린학원_자마린...
 
3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]
3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]
3. 안드로이드 애플리케이션 구성요소 3.2인텐트 part01(안드로이드학원/안드로이드교육/안드로이드강좌/안드로이드기업출강]
 

(자마린안드로이드예제실습)현재 위치를 얻은 후 지도에 표시하기, GPS다루기, 마시멜로이후 권한 획득방법 구현_추천자마린학원/자마린교육

  • 1. 크로스플랫폼 앱개발을 위한 자마린 기초강좌 Xamarin.Android 심플예제 현재 위치를 얻은 후 지도에 표시하기, 마시멜로 이후 권한 획득방법 구현 탑크리에듀(http://topcredu.co.kr), 이종철
  • 2. 예제 개요 – 프로젝트 생성  Android 개발자가 이용할 수있는 130 가지 이상의 고유 권한을 사용하여 응용프로그램에 서 사용할 권한을 정확히 알기 어렵다. Android Marshmallow는 사용 권한을 단순화 할뿐 만 아니라 필요한 사용 권한의 수를 줄이기 위해 응용 프로그램 사용 권한에 대해 완전히 새로운 방향을 제시하는 데 예제를 통해 알아보자.  폰접근 권한을 받아오고 GPS를 통해 위치 정보를 받아, 지도를 로딩하는 방법에 대한 실 습  “GetLocation“ 라는 이름의 Xamarin.Android 프로젝트 생성  AssemblyInfo.cs에 위치정보 서비스를 위한 두개의 권한을 허용  사용자 위치를 얻기 위해 GPS를 사용해야하는 경우 ACCESS_FINE_LOCATION 및 ACCESS_COARSE_LOCATION 권한을 지정하고 API 레벨 23(마시멜로) 이상에서 런타임시 사용자에게 요청하게 된다. 탑크리에듀(http://topcredu.co.kr), 이종철
  • 3. 예제 개요 - 권한  Android 애플리케이션에서 특정 API를 호출 할 때 필요한 모든 권한을 지정해야 한다. 즉, 사용자 위치를 얻기 위해 GPS를 사용해야하는 경우 ACCESS_FINE_LOCATION 및 ACCESS_COARSE_LOCATION 권한을 지정해야 했다. 사용 권한 그룹은 위치, 연락처, 전화, 센서, SMS 및 저장소와 같은 유사한 작업을 수행하는 사용 권한을 단순화하려고 시도하는 데 앱 그룹은 현재 1 ~ 7 개의 권한을 단일 권한 그룹으로 묶는데 한 번에 그룹의 모든 권 한을 요청할 수 있다.  이러한 권한 그룹 중 하나에서 찾은 권한 또는 일반으로 지정되지 않은 권한을 사용하는 경우 사용자에게 권한을 요청해야 한다.  Geolocator Plugin은 AccessFineLocation and AccessCoarseLocation 위치 권한을 모두 필요로하며, android.permission-group.LOCATION에 그룹화되어 있다. AndroidManifest.xml에 이 두 가지 권한을 추가해야 하며 런타임에 요청해야 한다.  [assembly: UsesPermission(Manifest.Permission.AccessFineLocation)]  [assembly: UsesPermission(Manifest.Permission.AccessCoarseLocation)] 탑크리에듀(http://topcredu.co.kr), 이종철
  • 4. 예제 개요 - 권한  AssemblyInfo.cs에 Geocoder 클래스를 사용하는 데 필요한 권한을 선언, 기기의 GPS 좌 표를 얻기 위해 꼭 필요한 것은 아니지만 본 예제에서는 현재 위치의 번지를 얻기 위해 사 용.[assembly: UsesPermission(Manifest.Permission.Internet)]  위3가지 권한을 Properties 더블클릭 후 Android 매니페스트에서 필수권한을 체크하자. 탑크리에듀(http://topcredu.co.kr), 이종철
  • 5. 텍스트뷰와 버튼을 위한 UI 생성, ResourcelayoutMain.axml  <?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/ap k/res/android"  android:orientation="vertical"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:paddingTop="20dp"  android:paddingLeft="8dp"  android:paddingRight="8dp"  android:id="@+id/main_layout"> 탑크리에듀(http://topcredu.co.kr), 이종철  <Button  android:layout_width="fill_parent"  android:textAppearance="?android:attr/textA ppearanceMedium"  android:layout_height="wrap_content"  android:id="@+id/get_permission_button"  android:text="Get Permission" />
  • 6. 텍스트뷰와 버튼을 위한 UI 생성, ResourcelayoutMain.axml  <Button  android:layout_width="fill_parent"  android:textAppearance="?android:attr/textA ppearanceMedium"  android:layout_height="wrap_content"  android:id="@+id/get_address_button"  android:text="Get Location" /> 탑크리에듀(http://topcredu.co.kr), 이종철  <TextView  android:layout_width="fill_parent"  android:textAppearance="?android:attr/textA ppearanceMedium"  android:layout_height="wrap_content"  android:text="Location (when available)"  android:id="@+id/location_text"  android:layout_marginBottom="15dp" />
  • 7. 텍스트뷰와 버튼을 위한 UI 생성, ResourcelayoutMain.axml  <TextView  android:layout_width="fill_parent"  android:textAppearance="?android:attr/textA ppearanceMedium"  android:layout_height="wrap_content"  android:text="Address (when available)"  android:id="@+id/address_text"  android:layout_marginTop="10dp" /> 탑크리에듀(http://topcredu.co.kr), 이종철  <Button  android:layout_width="fill_parent"  android:textAppearance="?android:attr/textA ppearanceMedium"  android:layout_height="wrap_content"  android:id="@+id/get_map_button"  android:text="Get Map" />  </LinearLayout>
  • 8. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;  using System.Threading.Tasks;  using Android.App;  using Android.Locations;  using Android.OS;  using Android.Util;  using Android.Widget;  using Android;  using Android.Content.PM;  using Android.Views;  using Android.Content; 탑크리에듀(http://topcredu.co.kr), 이종철  namespace GetLocation  {   [Activity(Label = "Get Location", MainLauncher = true, Icon = "@drawable/icon")]  public class MainActivity : Activity  {  static readonly string TAG = "[LOCATION APP]" + typeof(MainActivity).Name;  TextView addressText;  Location currentLocation;  LocationManager locationManager = null;  View layout;
  • 9. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  string locationProvider;  TextView locationText;   const int RequestLocationId = 0;  readonly string[] PermissionsLocation =  {  Manifest.Permission.AccessCoarseLocation,  Manifest.Permission.AccessFineLocation  }; 탑크리에듀(http://topcredu.co.kr), 이종철  protected override void OnCreate(Bundle bundle)  {  base.OnCreate(bundle);  SetContentView(Resource.Layout.Main);   addressText = FindViewById<TextView>(Resource.Id.address_text);  locationText = FindViewById<TextView>(Resource.Id.location_text);  layout = FindViewById<LinearLayout>(Resource.Id.main_layo ut);
  • 10. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  Button permission_button = FindViewById<Button>(Resource.Id.get_per mission_button);  permission_button.Click += PermissionButton_OnClick;   Button addr_button = FindViewById<Button>(Resource.Id.get_ad dress_button);  addr_button.Click += AddressButton_OnClick; 탑크리에듀(http://topcredu.co.kr), 이종철  Button map_button = FindViewById<Button>(Resource.Id.get_map _button);  map_button.Click += MapButton_OnClick;   }
  • 11. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  // 권한을 가져온다.  void PermissionButton_OnClick(object sender, EventArgs e)  {  if ((int)Build.VERSION.SdkInt < 23)  {  return;  } 탑크리에듀(http://topcredu.co.kr), 이종철  //Check to see if any permission in our group is available, if one, then all are  const string permission = Manifest.Permission.AccessFineLocation;  if (CheckSelfPermission(permission) == (int)Permission.Granted)  {  return;  }   //Finally request permissions with the list of permissions and Id  RequestPermissions(PermissionsLocation, RequestLocationId);  }
  • 12. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  // 사용자가 권한 요청을 승인하거나 거부 한 후에는 응답을 처리하고 기능을 켜거나 끔  // 권한이 요청 된 활동의 OnRequestPermissionsResult를 재정 의하여 수행  // 이 메소드는 결과 코드 (권한을 요청할 때 지정된 코드)와 부여 또는 거부 된 결과를 리턴  public override async void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)  { 탑크리에듀(http://topcredu.co.kr), 이종철  switch (requestCode)  {  case RequestLocationId:  {  if (grantResults[0] == Permission.Granted)  {  var callDialog = new AlertDialog.Builder(this);  callDialog.SetMessage("Permission Confirmed! ");  callDialog.SetNeutralButton("OK",  delegate  {  // Create intent to dial phone  });
  • 13. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  callDialog.Show();  return;  }  else  {  var callDialog = new AlertDialog.Builder(this);  callDialog.SetMessage("Permission Denied! "); 탑크리에듀(http://topcredu.co.kr), 이종철  callDialog.SetNeutralButton("OK",  delegate  {  // Create intent to dial phone  });  callDialog.Show();  return;  }  }  }  }
  • 14. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  // 지도를 표시한다.  async void MapButton_OnClick(object sender, EventArgs e)  {   if (currentLocation == null)  {  addressText.Text = "Can't determine the current address. Try again in a few minutes.";  return;  } 탑크리에듀(http://topcredu.co.kr), 이종철  Address address = await ReverseGeocodeCurrentLocation();   var geoUri = Android.Net.Uri.Parse("geo:" + address.Latitude.ToString()+", "+address.Longitude.ToString());  var mapIntent = new Intent(Intent.ActionView, geoUri);  StartActivity(mapIntent);  }
  • 15. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  // 위도와 경도를 읽고 에서 주소를 가져옴.  async void AddressButton_OnClick(object sender, EventArgs e)  {   InitializeLocationManager();   currentLocation = locationManager.GetLastKnownLocation(loc ationProvider); 탑크리에듀(http://topcredu.co.kr), 이종철  if (currentLocation == null) {  addressText.Text = "Can't determine the current address. Try again in a few minutes.";  return;  }  locationText.Text = string.Format("{0:f6},{1:f6}", currentLocation.Latitude, currentLocation.Longitude);  Address address = await ReverseGeocodeCurrentLocation();  DisplayAddress(address);  }
  • 16. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  // LocationManager 클래스는 장치에서 GPS 업데이트를 수신하고  // 이벤트를 통해 응용 프로그램에 알린다.  // 주어진 기준 세트와 일치하는 최고의 GPS 위치 제공자를 Android에 요청하고  // 그 제공자를 LocationManager에 제공한다.  void InitializeLocationManager()  {  locationManager = (LocationManager)GetSystemService(LocationService);  Criteria criteriaForLocationService = new Criteria  {  Accuracy = Accuracy.Fine  }; 탑크리에듀(http://topcredu.co.kr), 이종철  IList<string> acceptableLocationProviders = locationManager.GetProviders(criteriaForLoc ationService, true);   if (acceptableLocationProviders.Any())  {  locationProvider = acceptableLocationProviders.First();  }
  • 17. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  else  {  locationProvider = string.Empty;  }  Log.Debug(TAG, "Using " + locationProvider + ".");  } 탑크리에듀(http://topcredu.co.kr), 이종철  // 현재 위치의 Address 개체 컬렉션을 비동기 적으로 조회한다.  // 위치 및 네트워크 가용성과 같은 요소에 따라 하나 또는 여러 개의 주소가 리턴되는데  // 첫 번째 주소 (가능한 경우)는 Activity에 주소를 표시하는 DisplayAddress 메소드로 전달된다.  async Task<Address> ReverseGeocodeCurrentLocation()  {  Geocoder geocoder = new Geocoder(this);  IList<Address> addressList =  await geocoder.GetFromLocationAsync(currentLocation.Lat itude, currentLocation.Longitude, 10);
  • 18. MainActivity.cs 파일에 Button의 클릭 이벤트 코드 작성  Address address = addressList.FirstOrDefault();  return address;  } 탑크리에듀(http://topcredu.co.kr), 이종철  void DisplayAddress(Address address) {  if (address != null) {  StringBuilder deviceAddress = new StringBuilder();  deviceAddress.AppendLine(address.GetAddressLine(0));  // Remove the last comma from the end of the address.  addressText.Text = deviceAddress.ToString();  } else {  addressText.Text = "Unable to determine the address. Try again in a few minutes.";  } } }}