【问题标题】:Android: after installing an APK, the open button is disabledAndroid:安装APK后,打开按钮被禁用
【发布时间】:2016-03-18 12:11:25
【问题描述】:

我在很多地方读到问题与清单和第一个活动的定义有关。看来我做得很好,但在安装 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>

【问题讨论】:

  • 如果您没有看到该图标...您如何确定它已安装?
  • 当我单击 apk 附件(电子邮件)时,安装窗口打开,我单击安装,它有一个进度,然后有一条消息说它已安装但打开按钮被禁用。我还在设置中看到该应用程序 -> 应用程序

标签: android android-activity android-manifest


【解决方案1】:

你的问题是这样的:

    <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>

在这里,您是说此活动将在以下情况下启动:

  • Intent 的动作为MAINVIEW
  • Intent 具有LAUNCHERBROWSABLE的类别
  • Intent 有一个Urihttp 的方案和www.example.com 的主机

主屏幕启动器和设置应用不会创建这样的Intent,因此它们无法启动此活动。

要么:

  • 删除您所拥有的 VIEWBROWSABLE&lt;data&gt; 部分,或
  • 将它们移动到一个单独的 &lt;intent-filter&gt;:

    <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>
    

多个&lt;intent-filter&gt; 元素代表一个OR 操作:匹配第一个过滤器Intent 将适用于此活动。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,但可能是由不同的原因引起的。 运行以下命令行有效:

    adb uninstall com.company.mayapp
    

    【讨论】:

      猜你喜欢
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-26
      • 2012-10-29
      • 2020-09-11
      • 1970-01-01
      相关资源
      最近更新 更多