找回密码
 注册
搜索
查看: 1342|回复: 2

[讨论] 关于Android开发GPS程序的问题。

[复制链接]
发表于 2009-6-9 23:13:11 | 显示全部楼层 |阅读模式
写了简单的GPS程序, 但是貌似模拟器的GPS没有起来。
onStatusChanged里的arg1一直=1。
Android SDK用的1.5 ADT用的0.9.1


Java code
package com.example.android.gpstest;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

public class GPSTest extends Activity implements LocationListener {

    private LocationManager lm;
    private List<String> proList;
    private Location loc;

    private String PROVIDER_NAME = "my_test_provider";
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10l, 100l, this);
    }

    public void onLocationChanged(Location arg0) {
        String lat = String.valueOf(arg0.getLatitude());
        String lon = String.valueOf(arg0.getLongitude());
        Log.e("GPS", "location changed: lat=" + lat + ", lon=" + lon);
    }

    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub
        Log.e("GPS", "The provider " + provider + " is disabled");
    }

    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub
        Log.e("GPS", "The provider " + provider + " is enabled");
    }

    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
        if (arg1 == 0) {
            Log.e("GPS", arg0 + " is OUT OF SERVICE");
        } else if (arg1 == 1) {
            Log.e("GPS", arg0 + " is TEMPORARILY_UNAVAILABLE");
        } else {
            Log.e("GPS", arg0 + " is Available");
        }
    }
}
发表于 2009-6-27 21:24:03 | 显示全部楼层
总有错误提示信息吧?
点评回复

使用道具 举报

发表于 2009-12-3 15:10:31 | 显示全部楼层
有道理!
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-12-23 14:13 , Processed in 0.157467 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表