我该如何解决符号问题?

时间:2018-11-06 14:02:44

标签: java android

这是我的代码,但我面临找不到符号的问题:

package com.example.adeeb.gamecom;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.LocationListener;
import android.location.LocationManager;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends AppCompatActivity  {


Button btnShowLocation;
private static final int REQUEST_CODE_PERMISSION = 2;
String mPermission  = Manifest.permission.ACCESS_FINE_LOCATION;
GPSTracker gps;
TextView location;

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

    try
    {
        if(ActivityCompat.checkSelfPermission(this,mPermission)!= 
         MockPackageManager.PERMISSION_GRANTED){

            ActivityCompat.requestPermissions(this,new String[] 
            {mPermission},REQUEST_CODE_PERMISSION);
        }

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

    btnShowLocation = (Button) findViewById(R.id.button);
    btnShowLocation.setOnClickListener(new View.OnClickListener(){
        public void onClickView(View V)
        {
            gps = new GPSTacker(MainActivity.this);
            location = (TextView) findViewById(R.id.locationtext);
            if(((GPSTracker) gps).canGetLocation())
            {
                double latitude = ((GPSTracker) gps).getLatitude();
                double longitude = ((GPSTracker) gps).getLatitude();
                location.setText(latitude+" "+longitude);

            }

            else
            {
                ((GPSTracker) gps).showSettingsAlert();
            }
        }
    });
       }
     }

这给我一个错误

错误:找不到符号类GPSTracker

错误:找不到符号变量MockPackageManager

我该如何解决此问题,请帮忙?如何在mainactivity.java中启用GPSTracker?

0 个答案:

没有答案