如何显示弹出消息,而无需上下文 [英] How to show popup message without having a context

查看:195
本文介绍了如何显示弹出消息,而无需上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发将在两个 JVM 的Andr​​oid 使用的库。现在,我们需要实现试用期的通知。在其他平台(.NET和Mac),显示一个弹出消息框就足够了。但到目前为止,我无法找到一个方法来为Android做到这一点。

We are developing a library that will be used both in JVM and Android. And now we need to implement trial period notification. In other platforms (.Net and Mac) showing a popup message box was enough. But so far I cannot find a way to do this for Android.

问题是显示一些信息(烤面包或AlertDialog),我需要有一个实际的上下文。但由于我们的库不包含UI元素并没有涉及到任何方式UI,我们并不要求用户创建了组件时,通过上下文。

The problem is that to show some message (toast or AlertDialog), I need to have an actual context. But since our library doesn't contain UI elements and not related to UI in any way we are not asking a user to pass context when creating out components.

要短:


  • 我该怎么让敬酒(AlertDialog,通知),而无需从用户code通过上下文REFFERENCE。

  • 如果我不能,也许有人有在Android和Java实现审判模式更好的解决方案。

推荐答案

看样子,你真的不能表现出既不敬酒也不AlertDialog无需上下文。最紧密变体是提供您的图书馆的一些接口,用户应该执行。

It appears that you really can't show neither Toast nor AlertDialog without having a context. The most close variant is to provide some interface in your library that user should implement.

这篇关于如何显示弹出消息,而无需上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆