GeoFnecing类获取错误未知源发现错误

时间:2015-11-30 06:18:22

标签: java android android-googleapiclient

我是android的新手,我在GEoFencing类googlemap中遇到两天错误。所以请提供更好的解决方案

 public class GeoFencingeg extends Activity implements ConnectionCallbacks,OnConnectionFailedListener,LocationListener{

    LocationRequest lr;
    GoogleApiClient mclient;
    TextView txt;
    Location mLastLocation;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_geo_fencingeg);
        txt=(TextView)findViewById(R.id.tv);
        lr=LocationRequest.create();
        mLastLocation=new Location("");

        Toast.makeText(getApplicationContext(), "Google API"+GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()), Toast.LENGTH_LONG).show();
        try{
            mclient=new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(Plus.API,new Plus.PlusOptions.Builder().build())
                    .addScope(Plus.SCOPE_PLUS_LOGIN).build();
            mclient.connect();
        }
        catch(Exception e){
            Log.i("Exception", e.getMessage());
        }

    }


    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        super.onStart();

    }


    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        if(mclient.isConnected())
            mclient.disconnect();
    }


    @Override
    public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub
        txt.setText("Current Location"+location.toString());
    }

    @Override
    public void onConnectionFailed(ConnectionResult arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onConnected(Bundle arg0) {
        // TODO Auto-generated method stub
        lr.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        lr.setInterval(1000);
        LocationServices.FusedLocationApi.requestLocationUpdates(mclient, lr, this);
    }

    @Override
    public void onConnectionSuspended(int arg0) {
        // TODO Auto-generated method stu
        }
    }

编译错误时,GoogleApiClient.Builder()中发现了未知来源.Build()。

enter image description here

最佳解决方案

0 个答案:

没有答案