Add Uri to the main Activity to start implicitly and pass parameters

Under normal circumstances, the main activity cannot be started implicitly, but there is actually a way to add support by adding a new intent-filter definition.

<activity
  android:name=".ui.WelcomeActivity"
  android:label="@string/app_name">

  <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>

  <intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <!-- 在data里设置了scheme和host,则该Activity可以接收和处理类似于"data://welcome/XXX"的链接 -->
    <data
        android:host="welcome"
        android:scheme="data" />
  </intent-filter>

</activity>

 

Guess you like

Origin blog.csdn.net/chenzhengfeng/article/details/104970095