Android - 从任何地方启动通知?
我现在正在 android 上编码,并且我有一个启动和停止服务的活动。然而,与整个应用程序相关的是一个非 android java 应用程序,它与该应用程序一起在后台运行。我需要这个单独的活动才能启动通知,但我不知道如何执行此操作。我无法在我的活动或服务中创建静态方法,因为那样我将无法获取上下文。有办法做到这一点吗?
谢谢! NS
I'm coding on the android right now, and I have an Activity which starts and stops a Service. However, related to this whole application will be a non-android java application which runs in the background alongside this app. I need this separate activity to be able to launch a notification, but I don't know how to do this. I cannot create a static method in either my Activity or my Service since then I wouldn't be able to get the context. Is there a way to do this?
Thanks!
NS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯......Android 中没有真正支持“非 Android java 应用程序”。
如果它是一个
Activity
,只需使用NotificationManager
——Activity
是一个Context
。如果它是“非 android java 应用程序”,请将其重写为
Activity
或Service
。Ummm...there is no real support in Android for "a non-android java application".
If it is an
Activity
, just useNotificationManager
--Activity
is aContext
.If it is "a non-android java application", rewrite it such that it is an
Activity
orService
.