Android - 如何获取库上下文?
我正在开发一个基于库的 Android 应用程序,并尝试实现智能 C2DM 服务。
但是,在注册时,我需要使用我的库包名称而不是应用程序包名称。它适用于接收消息,但不适用于注册。
更深入地观察,我注意到了 register 方法。当然,它使用上下文来获取registrationIntent。 我的问题是此上下文返回应用程序包名称,而不是库包名称。我想用这个。
那么...是否有办法从库中获取上下文,其中包含与 lib 清单相对应的包名称? 或者,也许有一种方法可以手动将调用意图包名称设置为我的 lib 包?
感谢您的任何回答或线索:)
编辑: 我尝试使用我的 appPackageName
作为参数来使用“createPackageContext
”,但是当然,系统找不到它,并且出现了异常......
I'm working on an Android application that is based on a library, and trying to implement a smart C2DM service.
However, on registration, I need to use my library package name instead of the app package name. It works fine for receiving messages, but not for registration.
Looking a bit deeper, I noticed the register method. It of courses uses a context to get registrationIntent
.
My problem is that this context returns the app package name, and not the library package name. I want to use this one.
So... Is there anyway to get a context from the library, that would include a package name corresponding to the lib manifest?
Or, maybe is there a way to manually set the calling intent package name to my lib package?
Thanks for any answer or clue :)
Edit :
I tried with the "createPackageContext
" using my appPackageName
as a parameter, but of course, it is not found by the system and I got an exception...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
。库没有包名称。
图书馆没有上下文。
Libraries do not have package names.
Libraries do not have contexts.