1

I'm creating this geofencing app using the google sample tutorials. All works well except for this part which keeps showing an error:

In the SimpleGeofence.java, I have:

  public class SimpleGeofence{
...
public Geofence toGeofence() {
        // Build a new Geofence object
        return    new Geofence.Builder()
                       .setRequestId(getId())
                       .setTransitionTypes(mTransitionType)
                       .setCircularRegion(
                               getLatitude(),
                               getLongitude(),
                               getRadius())
                       .setExpirationDuration(mExpirationDuration)
                       .build();
    }

The error shows under the Geofence.Builder(), and I'm being asked to create a class 'Builder' in type 'Geofence'.

When I create the class under Geofence.java, the error moves to .setRequestId(getId()) and I'm asked to create a method 'setRequestId(String)' in the type 'Builder'. This is what i have in the Geofence.java after creating all these;

package com.kamerlabs.wocmantv;

public class Geofence {

    public class Builder {

        public Object setRequestId(String string) {
            // TODO Auto-generated method stub
            return null;
        }

    }
}

An error now shows on .setTransitionTypes(mTransitionType) and I'm asked to 'Add cast to method receiver'. This is where i need help..what should i do now. Thanks in advance!!

4

1 回答 1

0

您需要删除生成的 Geofence 类并继续使用 com.google.android.gms.location包中的类。将其导入您的 SimpleGeofence.java,如下所示。

import com.google.android.gms.location.Geofence;

接下来请确保您的getId()方法(在 中使用.setRequestId(getId()))返回一个字符串。

于 2013-08-18T18:00:45.083 回答