Intent

Intent:一个表示“启动意图”的对象

Activity : getIntent()获取当前Activity唯一Intent
 
显式调用Intent
Component
  1. Intent intent =newIntent();
  2. ComponentName comp =newComponentName(MainActivity.this,SecondActivity.class);
  3. intent.setComponent(comp);
  4. startActivity(intent);
  1. Intent intent =newIntent();
  2. intent.setclass(MainActivity.this,SecondActivity.class);
  3. startActivity(intent);
隐式调用Intent
Intent指定属性值(子集) ∈ <intent-filter>指定属性值(父集
 
<intent-filter>:
多个<action.../>
多个<category.../>
多个<data.../>
Intent:
addCategory(String):多个Category
addFlags(int) setFlag(int)
setAction(String):一个Action
setClass
setType
Action Category
  1. Intent intent =newIntent();
  2. intent.setAction(SOME_STRING);
  3. startActivity(intent);
Intent 对象中默认有category: android.intent.category.DEFAULT
action至少选一匹配;category须全匹配
  1. <intent-filter>
  2.     <action android:name="SOME_STRING"/>
  3.     <category android:name="android.intent.category.LAUNCHER"/>
  4. </intent-filter>
Data Type
intent<intent-filter>
setData(uri)
匹配顺序:scheme>> host>>port、path 
 setType(String mime)<data android:mimeType=""/>
data至少选一匹配
先后setData(uri)  setType(String mime) 会相互覆盖
同时: setDataAndType(Uri data, String type)
A .mim or .mme file is a file in the Multipurpose Internet Mail Extension (MIME) format.
 
MIME is a specification for the format of  non-text e-mail attachments(附件) that allows the attachment to be sent over the Internet. MIME allows your mail client or Web browser to send and receive things like spreadsheets and  audio, video and graphics files via Internet mail.
Extra
putExtra(Bundle)puExtra(String key,Xxx value)
Bundle getExtra()getXxxExtra(String key)
 
Bundle:
putXxx(String key,Xxx value)  putSerializable(String key,Serializable data)
getXxx(String key,Xxx defaultValue)
Flag
Set special flags controlling how this intent is handled. 
Most values here depend on the type of component being executed by the Intent, specifically the FLAG_ACTIVITY_* flags are all for use with Context.startActivity() and the FLAG_RECEIVER_* flags are all for use with Context.sendBroadcast(). 
etc.
FLAG_ACTIVITY_BROUGHT_TO_FRONT
FLAG_ACTIVITY_CLEAR_TASK
FLAG_ACTIVITY_CLEAR_TOP
FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
指定Action、Category调用系统Activity
 
 
 
 
 
 
 





转载于:https://www.cnblogs.com/Doing-what-I-love/p/5532995.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值