Android guistatic不能解析为变量

Android guistatic不能解析为变量,android,geolocation,gps,reverse-geocoding,Android,Geolocation,Gps,Reverse Geocoding,我正在尝试从以下代码中获取用户位置名称。我收到错误,因为guistatic无法解析为变量。如何纠正它。也可以告诉任何人这段代码是正确的方法,以实现位置名称与否 package com.example.location; import java.util.List; import java.util.Locale; import android.location.Address; import android.location.Criteria; import android.location

我正在尝试从以下代码中获取用户位置名称。我收到错误,因为guistatic无法解析为变量。如何纠正它。也可以告诉任何人这段代码是正确的方法,以实现位置名称与否

package com.example.location;

import java.util.List;
import java.util.Locale;

import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.telephony.CellLocation;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity implements LocationListener {
LocationManager lmanager;
String provider;
String er="Please try again";
TextView t;
public static Context mContext; 
private double latitude,longitude;


@Override
protected void onCreate(Bundle savedInstanceState) {
    mContext=this;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    t=(TextView)findViewById(R.id.textView1);

    lmanager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
    lmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    lmanager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);

    locationUpdate();


}

private void locationUpdate() {
    // TODO Auto-generated method stub
    CellLocation.requestLocationUpdate();
}

private void getAddress(double lat, double lon) {
    // TODO Auto-generated method stub
    Geocoder coder=new Geocoder(MainActivity.mContext,Locale.getDefault());
    try
    {
        List<Address> listaddress=coder.getFromLocation(lat, lon, 1);
        Address obj=listaddress.get(0);
        String add=obj.getAddressLine(0);
        GUIStatics.currentAddress=obj.getSubAdminArea()+","+obj.getAdminArea();
        GUIStatics.longitude=obj.getLongitude();
        GUIStatics.latitude=obj.getLatitude();
        GUIStatics.currentCity=obj.getSubAdminArea();
        GUIStatics.currentState=obj.getAdminArea();
        add = add + "\n" + obj.getCountryName();
        add = add + "\n" + obj.getCountryCode();
        add = add + "\n" + obj.getAdminArea();
        add = add + "\n" + obj.getPostalCode();
        add = add + "\n" + obj.getSubAdminArea();
        add = add + "\n" + obj.getLocality();
        add = add + "\n" + obj.getSubThoroughfare();
        Log.v("IGA", "Address" + add);
        Toast.makeText(this, "Address=>" + add,Toast.LENGTH_SHORT).show();


    }
    catch(Exception e)
    {
        e.printStackTrace();
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

@Override
public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
    latitude=location.getLatitude();
    longitude=location.getLongitude();
    GUIStatics.latitude=latitude;
    GUIStatics.longitude=longitude;
    Log.v("Test", "IGA" + "Lat" + latitude + "   Lng" + longitude);
    getAddress(latitude, longitude);
    if(location!=null)
    {
        lmanager.removeUpdates(this);
    }
}

@Override
public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub
    Toast.makeText(MainActivity.this, "Gps Disabled", Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(
            android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    startActivity(intent);
}

@Override
public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    // TODO Auto-generated method stub
    if(status == LocationProvider.TEMPORARILY_UNAVAILABLE)
    { 
        Toast.makeText(MainActivity.this,"LocationProvider.TEMPORARILY_UNAVAILABLE", Toast.LENGTH_SHORT).show(); 
    } 
    else if(status== LocationProvider.OUT_OF_SERVICE)
    { 
     Toast.makeText(MainActivity.this, "LocationProvider.OUT_OF_SERVICE", Toast.LENGTH_SHORT).show(); 
    } 


}

 }
package com.example.location;
导入java.util.List;
导入java.util.Locale;
导入android.location.Address;
导入android.location.Criteria;
导入android.location.Geocoder;
导入android.location.location;
导入android.location.LocationListener;
导入android.location.LocationManager;
导入android.location.LocationProvider;
导入android.os.Bundle;
导入android.app.Activity;
导入android.content.Context;
导入android.content.Intent;
导入android.telephony.CellLocation;
导入android.util.Log;
导入android.view.Menu;
导入android.widget.TextView;
导入android.widget.Toast;
公共类MainActivity扩展活动实现LocationListener{
地点经理;
字符串提供者;
String er=“请重试”;
文本视图t;
公共静态语境;
私人双纬度、经度;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
mContext=这个;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t=(TextView)findViewById(R.id.textView1);
lmanager=(LocationManager)getSystemService(Context.LOCATION\u服务);
lmanager.RequestLocationUpdate(LocationManager.GPS_提供程序,0,0,此);
lmanager.RequestLocationUpdate(LocationManager.NETWORK_提供程序,0,0,此);
位置更新();
}
私有void位置更新(){
//TODO自动生成的方法存根
CellLocation.requestLocationUpdate();
}
专用void getAddress(双lat,双lon){
//TODO自动生成的方法存根
Geocoder coder=新的Geocoder(MainActivity.mContext,Locale.getDefault());
尝试
{
List listaddress=coder.getFromLocation(lat,lon,1);
地址obj=listaddress.get(0);
字符串add=obj.getAddressLine(0);
GUIStatics.currentAddress=obj.getSubAdminArea()+”,“+obj.getAdminArea();
GUIStatics.longitude=obj.getLongitude();
GUIStatics.latitude=obj.getLatitude();
GUIStatics.currentCity=obj.getSubAdminArea();
GUIStatics.currentState=obj.getAdminArea();
add=add+“\n”+obj.getCountryName();
add=add+“\n”+obj.getCountryCode();
add=add+“\n”+obj.getAdminArea();
add=add+“\n”+obj.getPostalCode();
add=add+“\n”+obj.getSubAdminArea();
add=add+“\n”+obj.getLocation();
add=add+“\n”+obj.getSubthoroughe();
日志v(“IGA”、“地址”+添加);
Toast.makeText(这个“Address=>”+add,Toast.LENGTH_SHORT.show();
}
捕获(例外e)
{
e、 printStackTrace();
Toast.makeText(this,e.getMessage(),Toast.LENGTH_SHORT.show();
}
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.activity\u主菜单);
返回true;
}
@凌驾
已更改位置上的公共无效(位置){
//TODO自动生成的方法存根
纬度=位置。getLatitude();
longitude=location.getLongitude();
纬度=纬度;
经度=经度;
对数v(“测试”、“IGA”+“纬度”+“Lng”+经度);
getAddress(纬度、经度);
如果(位置!=null)
{
l管理者。删除更新(此);
}
}
@凌驾
公共无效onProviderDisabled(字符串提供程序){
//TODO自动生成的方法存根
Toast.makeText(MainActivity.this,“Gps禁用”,Toast.LENGTH_SHORT.show();
意图=新意图(
android.provider.Settings.ACTION\u LOCATION\u SOURCE\u Settings);
星触觉(意向);
}
@凌驾
公共无效onProviderEnabled(字符串提供程序){
//TODO自动生成的方法存根
}
@凌驾
public void onStatusChanged(字符串提供程序、int状态、Bundle extra){
//TODO自动生成的方法存根
如果(状态==位置提供程序。暂时不可用)
{ 
Toast.makeText(MainActivity.this,“LocationProvider.temporary\u UNAVAILABLE”,Toast.LENGTH\u SHORT.show();
} 
else if(状态==LocationProvider.OUT\u OF\u服务)
{ 
Toast.makeText(MainActivity.this,“LocationProvider.OUT\u OF\u SERVICE”,Toast.LENGTH\u SHORT.show();
} 
}
}
我的清单文件如下所示

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.location"
 android:versionCode="1"
 android:versionName="1.0" >
<uses-permission android:name="android.permission.ACCESS_GPS"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="8" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-library android:name="com.google.android.maps" />
    <activity
        android:name="com.example.location.MainActivity"
        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>


提前谢谢。请帮帮我

你有解决办法吗/