gpt4 book ai didi

java - 如何静态检索 Instagram 位置的当前 LAT 和 LNG?

转载 作者:太空宇宙 更新时间:2023-11-04 14:01:59 25 4
gpt4 key购买 nike

private static final String CLIENT_ID = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
private static final String PARAM_NAME_CLIENT_ID = "client_id";
private final int COUNT = 100;
private static final String instagramAPI = "https://api.instagram.com/v1/media/search?";
private static LatLng mLatLng;
private static final String LAT = "lat=";
private static final String LNG = "&lng=";
private static final String distance = "&distance=";
static Location location;
GoogleMap map;
private Context context;
static double latitude;
static double longitude;
public InstagramPhotosClient(double latitude, double longitude) {


}


LocationManager service = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = service.getBestProvider(criteria, false);
Location location1 = service.getLastKnownLocation(provider);
LatLng userLocation = new LatLng(location.getLatitude(),location.getLongitude());

public static String getRequestCacheKey() {
return String.valueOf(latitude) + String.valueOf(longitude);
}
private static AsyncHttpClient client = new AsyncHttpClient();

public static void getPopularPhotos(AsyncHttpResponseHandler handler) {
String url = instagramAPI + LAT + latitude + LNG
+ longitude;
RequestParams params = new RequestParams();
params.put(PARAM_NAME_CLIENT_ID, CLIENT_ID);
client.get(url, params, handler);
}

}

我必须使用loopj http jsonhttpresponsehandler静态引用另一个类中的url,但是我不认为我可以使用谷歌地图lat和lng静态找到我当前的位置。

最佳答案

我认为您需要在声明 LocationManager 之后、从 getLastKnownLocation 获取经度和纬度之前设置它。这就是我的处理方法:

    LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, new LocationListener() {
@Override
public void onStatusChanged(String s, int i, Bundle bundle) {}
@Override
public void onProviderEnabled(String s) {}
@Override
public void onProviderDisabled(String s) {}
@Override
public void onLocationChanged(final Location location) {}
});
Location myLocation = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
double longitude = myLocation.getLongitude();
double latitude = myLocation.getLatitude();

关于java - 如何静态检索 Instagram 位置的当前 LAT 和 LNG?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29219892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com