Android中的意图是什么? [英] What is an Intent in Android?

查看:150
本文介绍了Android中的意图是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 什么是Android中的意图?
  • 有人可以举例说明吗?
  • 意图的类型是什么,为什么我们要使用它们?
  • 为什么Intent在Android中如此重要?
  • What is an Intent in Android?
  • Can someone elaborate with an example?
  • What are the types of Intents, and why we are using them?
  • Why are Intents so important in Android?

推荐答案

一个意图是执行动作的意图";换句话说,

An Intent is an "intention" to perform an action; in other words,

可用于从另一个应用程序组件请求操作的消息传递对象

a messaging object you can use to request an action from another app component

Intent基本上是一条消息,表明您已完成或希望发生某些事情.根据意图,应用程序或操作系统可能正在监听它,并会做出相应的反应.可以将其视为发送给一群朋友的爆炸性电子邮件,您可以在其中告诉您的朋友约翰做某事,或者是可以做X的朋友()来执行X.其他人将忽略该电子邮件,但John(或可以执行X的朋友)将对此做出反应.

An Intent is basically a message to say you did or want something to happen. Depending on the intent, apps or the OS might be listening for it and will react accordingly. Think of it as a blast email to a bunch of friends, in which you tell your friend John to do something, or to friends who can do X ("intent filters"), to do X. The other folks will ignore the email, but John (or friends who can do X) will react to it.

要收听广播意图(例如电话响起或收到SMS),请实现广播接收器,该接收器将被传递意图.要声明您可以处理他人的应用程序意图(例如拍照"),请声明

To listen for an broadcast intent (like the phone ringing, or an SMS is received), you implement a broadcast receiver, which will be passed the intent. To declare that you can handle another's app intent like "take picture", you declare an intent filter in your app's manifest file.

如果您想激发执行某项操作的意图,例如弹出拨号器,则开除意图说您愿意.

If you want to fire off an intent to do something, like pop up the dialer, you fire off an intent saying you will.

这篇关于Android中的意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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