Amo*_*mos 0 android android-manifest android-activity
我在很多地方读到这个问题与清单和第一个活动的定义有关.似乎我做得很好但是在安装APK之后仍然打开按钮被禁用,我在设备上看不到图标
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.example.com"/>
</intent-filter>
</activity>
<activity android:name=".DateSelectorActivity"
android:label="@string/app_name">
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
你的问题是这样的:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.example.com"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
在这里,您说只有在以下情况下才会启动此活动:
Intent具有的作用MAIN或VIEW,和Intent具有的类别LAUNCHER或BROWSABLE,和Intent拥有Uri与的方案http和主机www.example.com主屏幕启动器和设置应用程序将不会创建此类Intent,因此他们无法启动此活动.
或者:
VIEW,BROWSABLE和<data>你有什么部分,或将它们分成一个单独的 <intent-filter>:
<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.BROWSABLE" />
<data android:scheme="http"
android:host="www.example.com"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)多个<intent-filter>元素表示OR操作:Intent匹配第一个过滤器或第二个过滤器将适用于此活动.