构造函数中的错误 [英] error in constructor

查看:42
本文介绍了构造函数中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何删除此错误



how i can remove this error

Implicit super constructor Provider.Service() is undefined. Must explicitly invoke another constructor
















public class GPSTracker extends Service implements LocationListener{

	 final Context context;
	boolean isGPSEnable=false;
	boolean isNetworkEnable=false;
	
	boolean canGetLocation=false;
	Location location;
	double latiude;
	double longitude;
	private static final long min_time_between_updates=1000*60*1;
	private static final long min_diatance_cahnge_for_updates=10;
	
	protected LocationManager locationManager;
	
	
	
	public GPSTracker(Context context) {
	
	this.context=context;
	getlocation();
	
	}
	

	public Location getlocation(){
		try{
			locationManager=(LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
			isGPSEnable=locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
			isNetworkEnable=locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);			
			
			if (isGPSEnable&&!isNetworkEnable) {
				
			}
			else{
				
				
				this.canGetLocation=true;
				if(isNetworkEnable){
					locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,min_time_between_updates, 
							min_diatance_cahnge_for_updates,  this);
					if(locationManager!=null){
						
						location=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
						if(location!=null){
							latiude=location.getLatitude();
							longitude=location.getLongitude();							
						}//third inner						
					}//inner second					
				}//main if
				if(isGPSEnable){
					locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,min_time_between_updates, 
							min_diatance_cahnge_for_updates,  this);
					if(locationManager!=null){
						
						location=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
						if(location!=null){
							latiude=location.getLatitude();
							longitude=location.getLongitude();							
						}//third inner						
					}//inner second					
				}//main if
				
				
				
				
			}
			
			
			
		}catch(Exception e){			
			e.printStackTrace();			
		}

推荐答案

有时,当您进行项目设置时,Eclipse会出现此错误 - 系统配置不匹配。



例如,如果您将Java 1.7项目导入Eclipse并且没有正确设置1.7,那么您将收到此错误。然后你可以去Project - Preference - Java - Compiler并切换到1.6或更早版本;或者转到Window - Preferences - Java - 已安装的JRE并添加/修复您的JRE 1.7安装。



您也可以尝试清理和构建工作区(菜单项目 - >清洁......)
Sometimes, Eclipse gives this error when you have project setup - system configuration mismatch.

For example if you import Java 1.7 project to Eclipse and you do not have 1.7 correctly set up then you will get this error. Then you can either go to Project - Preference - Java - Compiler and switch to 1.6 or earlier; or go to Window - Preferences - Java - Installed JREs and add/fix your JRE 1.7 installation.

You can also try to clean and build the workspace (menu Project -> Clean...)


这篇关于构造函数中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆