android平台上GPS訊號的擷取和展示(三)之配置與模擬器設定

來源:互聯網
上載者:User

1. 除了前面提到的主要java模組代碼,還需要在檔案AndroidManifest.xml檔案中修改許可權:

在uses-permission中,代碼如下:

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"      package="zfy.mygps"      android:versionCode="1"      android:versionName="1.0">    <uses-sdk android:minSdkVersion="8" />    <application android:icon="@drawable/icon" android:label="@string/app_name"    android:debuggable="true">        <activity android:name=".Mygps"                  android:label="@string/app_name"                  android:screenOrientation="portrait">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>     </application>       <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />     <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/></manifest>

2. 在運行中若要在模擬器中運行,還需要模擬器支援GPS,這一點開啟模擬器的時候不一定開啟了,模擬器對GPS的支援設定如下:

Eclipse軟體中:window--->android sdk and avd manager ,開啟模擬器管理視窗,如果已經有可用的模擬器,則開啟edit,如果沒有就建立一個模擬器,如:

然後在HardWare右邊的視窗中可以看到是否有對GPS的支援,如果沒有,則點擊右邊的new,彈出如下的視窗:

從中選擇對GPS的支援,然後ok退出。

這樣模擬器就支援GPS了,可以利用模擬器來測試你的程式,

3.利用Eclipse中的Emulator Control來測試定位;

window-->show view --> Emulator Control(如果在show view當中沒有Emulator Control,則在other菜單中),如果沒有開啟模擬器,則emulator control中為灰色,不能編輯,如果模擬器開啟之後還是為灰色,則重啟eclipse(模擬器不要關)


之前網上有資料說gps在android2.2或以下才支援,在android2.2和android2.3中都測試通過。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.