Android的IBeaconManager没有活动连接 [英] Android IBeaconManager not connecting from activity
问题描述
我使用的是iBeacon显示SDK从android的半径网络。即时通讯目前使用IBeaconManager在一个活动,一个服务。当应用程序第一次启动,活动然而结合其iBeaconManager对象 onIBeaconServiceConnect
不会被调用。调用任何范围或监视功能的前 startRangingBeaconsInRegion(区)
抛出一个RemoteException的:
的IBeaconManager未绑定到该服务。呼叫iBeaconManager.bind(IBeaconConsumer消费者),并等待回调onIBeaconServiceConnect()
出人意料的是, iBeaconMananger.isBound(myActivity)
终止返回true。
现在,当我开始我的服务(从我的活动解除绑定,并将绑定到我的服务),绑定工作正常,我就可以开始监测信标。如果当时,我再次打开活动(从我的服务解除绑定和绑定到我的活动之后),它现在在我的活动了。
因此,只有当应用程序第一次启动时, onIBeaconServiceConnect()
没有被要求我的活动。
任何帮助是极大的AP preciated。
更新
MyActivity
( BaseActivity
是活动的一个子类
):
公共类MyActivity扩展BaseActivity实现IBeaconConsumer { 私人IBeaconManager iBeaconManager;
的LocationManager的LocationManager; 公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.new_survey); 的LocationManager =(的LocationManager)this.getSystemService(Context.LOCATION_SERVICE); ... iBeaconManager = IBeaconManager.getInstanceForApplication(本);
iBeaconManager.bind(本);
} @覆盖
公共无效onIBeaconServiceConnect(){
Log.d(MyTag的,航标连接服务);
iBeaconManager.setRangeNotifier(新RangeNotifier(){
@覆盖
公共无效didRangeBeaconsInRegion(收集和LT; iBeacon显示> iBeacons,地区区){
Log.d(MyTag的,没有范围信标); });
}
}
我结束了移动beaconManager到我的应用
的子类,而不是在我的活动中使用它。
I'm using the IBeacon SDK from radius networks on the android. Im currently using the IBeaconManager in one Activity and one Service. When the app first launches, The activity binds its iBeaconManager object however onIBeaconServiceConnect
never gets called. Calling any ranging or monitoring functions ex startRangingBeaconsInRegion(region)
is throwing a RemoteException:
The IBeaconManager is not bound to the service. Call iBeaconManager.bind(IBeaconConsumer consumer) and wait for a callback to onIBeaconServiceConnect()
Surprisingly, iBeaconMananger.isBound(myActivity)
is returning true.
Now when I start my service (unbind from my activity and bind to my service), the binding works fine and I can start monitoring for beacons. If then, I open the activity again (after unbinding from my Service and binding to my Activity), it now works in my Activity too.
So only when the app first launches, the onIBeaconServiceConnect()
is not being called for my Activity.
any help is greatly appreciated.
Update
MyActivity
(BaseActivity
is a subclass of Activity
):
public class MyActivity extends BaseActivity implements IBeaconConsumer {
private IBeaconManager iBeaconManager;
LocationManager locationManager;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_survey);
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
...
iBeaconManager = IBeaconManager.getInstanceForApplication(this);
iBeaconManager.bind(this);
}
@Override
public void onIBeaconServiceConnect() {
Log.d("mytag","beacon service connected");
iBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<IBeacon> iBeacons, Region region) {
Log.d("mytag","did range beacons");
});
}
}
I ended up moving the beaconManager to my Application
subclass instead of using it in my activity.
这篇关于Android的IBeaconManager没有活动连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!