zoukankan      html  css  js  c++  java
  • 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
     
     
     
     
     
     
     





  • 相关阅读:
    [NOIP2013] 提高组 洛谷P1979 华容道
    Vijos P1404 遭遇战
    CodeVS 1506 传话
    P1546 最短网络 Agri-Net
    HDU 4747 Mex
    POJ1020 Anniversary Cake
    【数据结构】平衡二叉树
    【数据结构】二叉排序树
    【数据结构】二叉树
    概念源于生活
  • 原文地址:https://www.cnblogs.com/Doing-what-I-love/p/5532995.html
Copyright © 2011-2022 走看看