【问题标题】:installed application from Android Studio opens another activity instead of launcher activity从 Android Studio 安装的应用程序打开另一个活动而不是启动器活动
【发布时间】:2017-01-08 00:27:11
【问题描述】:

每当我从 Android 工作室运行我的应用程序时,一个具有

的 Activity
android:exported="true"

启动而不是启动器活动

<activity
        android:name=".activity.SplashScreen"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar"
        android:windowSoftInputMode="stateHidden|adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

但是一旦安装了应用程序,正确的启动器活动就会打开,没有问题。 只有当我从 Android Studio 启动我的应用程序(即通过运行应用程序)时才会出现问题。那么为什么会这样呢?

如果没有android:exported="true",在某些设备上,单击我的应用通知后不会启动该活动。那么保持export true好不好?

我也不能在这里发布我的整个清单

【问题讨论】:

  • manifest.xml,请启动器活动代码
  • 也许检查您的运行配置?运行 -> 编辑配置
  • “如果没有 android:exported="true",在某些设备上,单击我的应用通知后不会启动该活动”——这是一个单独的问题。您无需导出活动即可通过 Notification 使用的 PendingIntent 打开它。
  • @CommonsWare 不是单独的问题,但想知道这就是我为该活动添加 android:exported="true" 的原因,并想知道是否有任何其他替代 android:exported= “真”
  • "想知道是否有任何其他替代 android:exported="true"" - 使用 android:exported="false"。如果您在某些设备上遇到问题,请发布一个单独的 Stack Overflow 问题,并附上 minimal reproducible example 并说明您在哪些设备上遇到的问题。

标签: android android-studio android-activity launcher run-app


【解决方案1】:

从 Android Studio 运行应用时,您可能使用的是即时运行。它将代码更改应用到应用程序的当前运行进程,因此无需再次安装应用程序,而是将新更改应用到正在运行的应用程序,在这种情况下,您会看到当前正在运行的活动。

http://android-developers.blogspot.com.eg/2016/04/android-studio-2-0.html https://developer.android.com/studio/run/index.html

【讨论】:

    【解决方案2】:

    如果它只发生在 Android Studio 中而不是在安装应用时发生,则很可能是运行配置有问题。您可以通过

    访问它

    运行 -> 编辑配置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-05
      • 1970-01-01
      • 2020-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多