Lập trình Android: Tự động cập nhật vị trí doc

3 238 0
Lập trình Android: Tự động cập nhật vị trí doc

Đang tải... (xem toàn văn)

Thông tin tài liệu

Trung tâm Tin học – ĐH KHTN Cập nhật vị trí của bạn trên bản đồ Project: Project name: TestNg22Th11 Build Target: Android 2.3.3 Google APIs Application name: TestNg22Th11 Package name: com.dac Create Activity: TestNg22Th11Activity File main: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.google.android.maps.MapView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="MAP KEYS" /> </LinearLayout> File Activity: package com.dac; import android.os.Bundle; import com.google.android.maps.*; public class TestNg22Th11Activity extends MapActivity { MapView mv; MyLocationOverlay myOverlay; GeoPoint pt; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Lập trình Android – http://laptrinhdidong.vn Page 1 Trung tâm Tin học – ĐH KHTN mv = (MapView)findViewById(R.id.MapView); mv.setBuiltInZoomControls(true); myOverlay = new MyLocationOverlay(this, mv); mv.getController().setZoom(17); pt = myOverlay.getMyLocation(); if(pt!=null) mv.getController().animateTo(pt); mv.getOverlays().add(myOverlay); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); myOverlay.disableMyLocation(); } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); myOverlay.enableMyLocation(); pt = myOverlay.getMyLocation(); if(pt!=null) mv.getController().animateTo(pt); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } Lập trình Android – http://laptrinhdidong.vn Page 2 Trung tâm Tin học – ĐH KHTN Bạn có thể gữi thông tin giả định vị trí của bạn trong DDMS để test ứng dụng trong Virtual Device Mọi ý kiến đóng góp các bạn vui lòng gữi về www.forum.laptrinhdidong.vn . rất mong nhận được ý kiến đóng góp của các bạn Lập trình Android – http://laptrinhdidong.vn Page 3 . Trung tâm Tin học – ĐH KHTN Cập nhật vị trí của bạn trên bản đồ Project: Project name: TestNg22Th11 Build Target: Android 2.3.3 Google. xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.google.android.maps.MapView android:id="@+id/MapView" . android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="MAP KEYS"

Ngày đăng: 10/08/2014, 11:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan