他の何人かの人々と私はアンドロイド用のアプリに取り組んでいます。デバイスを緯度と経度に配置する必要があります。ロケーションオブジェクトを作成できましたが、オブジェクトは常に空白です。完全に空のプロジェクトでコードを再作成しようとしましたが、それも失敗しました。これが私たちのルートアクティビティです:
package com.app.Locationtest;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
public class locationtest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager locman =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location loc = locman.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (loc==null)
{
finish();
}
}
}
マニフェストは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.Locationtest"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".locationtest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
この問題をどのように修正しますか?