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
 
 
 
 
 
 
 





posted @ 2016-05-26 22:51  _Doing  阅读(143)  评论(0编辑  收藏  举报