0

The premise is I am writing a library that in itself uses and implements the IBeacon SDK. My code has to implement that SDK, does things and if someone uses my library they dont have to interact with this SDK at all, so I'm making a higher level codebase you could say.

Now my code cannot use any activities by itself, its just a library, another user will then implements my code. So my code needs to consume the IBeacon events and do something with it without being an activity by itself.

So I would implement IBeaconConsumer myself and then the person using my library would just give me an activity / context and I would pass it to the IBeacon SDK.

Doing so results in the following problem (with proper mainfest code):

The activity binds its iBeaconManager object however onIBeaconServiceConnect never gets called. See this stackoverflow question: Android IBeaconManager not connecting from activity

My vague assumption is this: the class implementing IBeaconConsumer is not an activity and its not the same class as the one I am binding the IBeacon service to and that might create the problem. Its just very hard to debug since it all works, no errors, just no ibeacon activity - same behavior as if you forget to add the part in the manifest

4

1 回答 1

1

如果您希望您的IBeaconConsumer实现不是Activity或 a的实例Service,那么您只需将bindServiceandunbindService方法链接到有效ApplicationContext实例,并从该getApplicationContext方法返回该有效实例。当您使用 an 实现此接口时,不需要这样做Activity,因为 anActivity为您实现了这三个方法。

您可以在此处的相关问题中查看此示例。

于 2014-05-13T01:17:16.930 回答