我正在使用 radiusnetworks 发布的 AndroidIbeacon 库,并且能够成功运行他们的演示应用程序。但是当我将它添加到我的应用程序时,不会调用 onIBeaconServiceConnect() 方法。
在我的代码下面,
public class Sample extends Activity implements IBeaconConsumer {
protected static final String TAG = "Sample";
private IBeaconManager iBeaconManager = IBeaconManager
.getInstanceForApplication(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
iBeaconManager.bind(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
iBeaconManager.unBind(this);
}
@Override
public void onIBeaconServiceConnect() {
iBeaconManager.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw an iBeacon for the firt time!");
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an iBeacon");
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG,
"I have just switched from seeing/not seeing iBeacons: "
+ state);
}
});
try {
iBeaconManager.startMonitoringBeaconsInRegion(new Region(
"myMonitoringUniqueId", null, null, null));
} catch (RemoteException e) {
}
}
}
请帮我解决这个问题。谢谢