我正在嘗試編寫一個Android應用程序以進行投放。很大一部分是找到移動設備的當前位置。Android應用程序 - 位置服務的@Override方法中的錯誤
我遵循的所有教程都給出了我無法弄清楚或理解的相同錯誤,我是Android開發新手。
我收到的錯誤是「錯誤:(76,5)錯誤:方法沒有覆蓋或實現超類型的方法」。
我的代碼:
public class LoginActivity extends AppCompatActivity {
protected LocationManager locationManager;
protected LocationListener locationListener;
protected Context context;
String tempLocation;
String lat;
String provider;
protected String latitude,longitude;
protected boolean gps_enabled,network_enabled;
public static String pName;
public static String pID;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
//Get Input
etUsername = (EditText) findViewById(R.id.txtLoginUserName);
etPassword = (EditText) findViewById(R.id.txtLoginPassword);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, (LocationListener) this);
}
@Override
public void onLocationChanged(Location location) {
tempLocation = "Latitude:" + location.getLatitude() + ", Longitude:" + location.getLongitude();
TextView lg = (TextView) findViewById(R.id.txtLoginUserName);
lg.setText(tempLocation);
}
@Override
public void onProviderDisabled(String provider) {
Log.d("Latitude","disable");
}
@Override
public void onProviderEnabled(String provider) {
Log.d("Latitude","enable");
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d("Latitude","status");
}
和我的結果日誌:
Error:(76, 5) error: method does not override or implement a method from a supertype
Error:(83, 5) error: method does not override or implement a method from a supertype
Error:(88, 5) error: method does not override or implement a method from a supertype
Error:(93, 5) error: method does not override or implement a method from a supertype
:app:compileDebugJavaWithJavac FAILED
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 1.661 secs
Information:5 errors
Information:0 warnings
Information:See complete output in console
我用這tutorial。
任何幫助或建議,將不勝感激,因爲我試圖使用許多不同的答案,但目前爲止沒有真正的幫助。
顯示您的類聲明。 – shmosel
你班上的班級是什麼? –
添加了行公共類LoginActivity延伸AppCompatActivity,希望你的意思是@shmosel – GoodDisplayName