我可以无意识地做某事吗?或者在某些情况下我必须使用它们?

发布于 2025-01-05 16:19:46 字数 270 浏览 4 评论 0原文

假设我想发送短信或电子邮件。我是否必须为此使用意图(调用操作系统本机服务)或者我可以发送短信/电子邮件/彩信/等。从应用程序内?是否可以在不打开操作系统本机服务/工具屏幕的情况下执行此操作?

我找到的所有材料都通过使用意图来解释这些任务。我想知道我是否真的必须依赖意图。

附言。我知道它们是处理事情的推荐方式,但不是强制性的。当我开发条形码扫描应用程序时,客户不允许使用外部应用程序(通过意图调用),但他希望在应用程序内完成这一切。那么为什么我不应该对短信/电子邮件/彩信/等做同样的事情呢?!

Let's say I want to send SMS or Email. Do I have to use intent for this (which calls OS native service) or I can send SMs/Email/MMS/etc. from within the app? Is it possible to do this without opening OS native services/tools screen?

All material I found explain these tasks by using intents. I was wondering if I really have to rely on intents.

PS. I know that they are recommended way of dealing with things, but not mandatory. When I develop bar-code-scanning app, a client will not allow using external app (called via intent), but he'd like to do it all within the app. So why shouldn't I do the same with sms/email/mms/etc.?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦醒灬来后我 2025-01-12 16:19:46

对于短信或电子邮件,您当然可以调用允许您发送消息的本机方法。这些意图只是另一种选择 - 如果您不想自己创建短信/电子邮件发送者活动。
发送短信:

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, message, null, null);

另请检查 用于在后台发送电子邮件。

For SMS or Email you can of course invoke native methods that allow you send messages. These intents are just another option - if you don't want to create the sms/email sender activity yourself.
Sending sms:

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, message, null, null);

Also check this out for sending email in the background.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文