发送短信后删除或使用弹出窗口
我有一个 Android 应用程序需要不断发送短信。我的问题是,每当我们发送消息时,我们都会弹出一个窗口(您的短信费用和手机中当前的通话时间余额)。当我发送许多短信时,这些弹出窗口会不断累积,这对我来说是不受欢迎的。我需要一种方法来删除或以某种方式消耗这些弹出窗口。 有什么想法吗?
I have an android app which needs to keep sending SMS. My problem is that whenever we send a message we get a pop up showing (your SMS charges and your curent talktime balance in phone). When i send many SMS these pop ups keep getting accumulated one over the other which is undesirable for me. I need a way out to either remove or somehow consume these pop ups.
Any ideas ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
弹出窗口?你是说吐司吗?或者通知堆积在状态栏下方?
你必须原谅我看似简单的问题。在美国,我在至少两个运营商上拥有多部 Android 手机,而且我没有收到任何形式的此类消息,但这可能是因为我一直有无限的短信,所以额外的短信不会花费我任何费用。
我敢打赌您正在谈论状态栏中累积的通知。因此,如果您的运营商正在这样做,请查看“API 演示”> 中的代码。应用程序>通知>状态栏
在附加到“清除通知”按钮的回调中,您将找到您要查找的代码。
如果我可以提出一些建议,我知道许多通知堆积在一起可能会非常烦人,但是如果您可以尝试将所有这些通知合并为一个通知,至少具有运行计数(除非您的用户明确选择退出)正在通知中)。通过这种方式,您仍然可以向用户传达信息中最重要的部分 - 到目前为止他的手机总共发送了多少条短信,而不会因为一遍又一遍地发生基本上相同的事件的许多通知而完全压倒他。
对于那些不知道的人,“API 演示”是一个免费的应用程序,您可以从市场下载。而且可能有好几个可供选择,所以就选旁边有五颗星的那个吧,但是“API Demos”也是你用 SDK Manager 下载时不同 SDK 附带的示例代码是一样的,你可以访问当您使用 Eclipse 中的“新建 Android 项目...”向导创建新的 Android 项目,然后选择单选按钮“从示例创建现有项目”(或类似的东西,我面前没有 Eclipse)时,该代码,因此措辞可能略有不正确)。当然,如果您不使用 Eclipse,您始终可以通过示例代码目录本身找到该示例代码。
作为一种可能更优雅的替代方案,或者可能只是为了防止您的运营商确实足够粗鲁,每次发送文本时都会弹出一个实际的模式对话框,您的运营商可能正在使用广播接收器来触发这些通知或那些对话框,因此,如果是这种情况,并且希望运营商不使用“100”作为其接收器的优先级,则您可以使用“100”注册接收器,然后在广播传播到之前终止广播其他接收者。但当然,这是假设您的运营商是这样设计的。
a pop up? Do you mean a toast? or notifications accumulating below the status bar?
You'll have to pardon my seemingly simple question. In the US, I've had multiple Android phones on at least two carriers, and I don't get any such message in any form, but may be that's because I've always had unlimited texting so additional texts do not cost me anything.
I bet you're talking about notifications accumulating in the status bar. So if your carrier is doing that, take a look at the code in the "API Demos" > App > Notification > Status Bar
There in the callback attached to the "Clear Notification" button, you'll find the code you're looking for.
And if I could suggest something, I know that many notifications accumulating on top of each other can be super annoying, but if you can try to consolidate all those notifications into one notification at least with the running count (unless your user explicitly opts out from being notified). This way, you still communicate to the user the most important part of the information - how many texts in total his phone has been sending so far, without completely overwhelming him with many-many notifications about basically the same event happening over and over again.
For those who don't know, "API Demos" is a free application you can download from the Market. And there may be several to choose from, so just pick the one with five stars next to it, but "API Demos" is also the same sample code that comes with different SDKs when you download it with the SDK Manager, and you can access that code when you create a new Android Project with the New Android Project... wizard from within Eclipse and then select the radio button "Create Existing Project from Sample" (or something like that, I don't have Eclipse in front of me, so the wording may be slightly incorrect). And of course, if you don't use Eclipse, you can always find that sample code through the Sample code directory itself.
As a potentially more elegant alternative, or may be just in case your carrier is indeed crude enough to pop up an actual modal dialog every time a text is sent, it may be that your carrier is using a broadcast receiver to trigger those notifications or those dialogs, so if that's the case, and hopefully the carrier isn't using "100" as a priority for its receiver, it may be possible for you to register a receiver with "100", and then kill the broadcast before it propagates to the other receivers. But of course, that's assuming that your carrier designed it that way for you.