android - Android 启动器 Activity 问题

标签 android android-activity manifest launcher

我为我的 Android 应用程序创建了一个启动屏幕。在我的 AndroidManifest 中,我将 SplashScreen Activity 设置为 Launcher,将操作设置为 MAIN。之后我更改了 HomeActivity 的 Intent 过滤器。 这是我的 Android list 文件:

<application
        android:allowBackup="true"
        android:icon="@mipmap/icon"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".SplashScreenActivity"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        </activity>

        <activity
            android:name=".ActivityHome"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.ACTIVITHOME" />

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

        <receiver android:name=".Receivers.NetworkReceiver"></receiver>


    </application>

我在默认包中拥有这两项 Activity 。现在,当我尝试在设备中测试应用程序时,出现以下错误:

Error while executing: am start -n "com.sdz.myapp/com.sdz.myapp.SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sdz.myapp/.SplashScreenActivity }
Error type 3
Error: Activity class {com.sdz.myapp/com.sdz.myapp.SplashScreenActivity} does not exist.

Error while Launching activity

这就是我的项目结构:

src
-com.sdz.myapp
----ActivityHome
----SplashScreenActivity

我重新启动了android studio,但错误仍然存​​在。我不知道是什么原因造成的。

最佳答案

我也遇到过这个问题。实际上,我必须先从设备上卸载该 apk,然后它才能工作...这真的很奇怪,因为该应用程序没有显示在我手机上的应用程序列表中。

这就是我所做的:

  1. 打开命令行
  2. 运行“adb devices”以确保我的设备已连接
  3. 运行“adb uninstall”替换为“com.whatever.blah”
  4. 您应该会看到一条消息,表明已成功卸载
  5. 再次尝试从 Android Studio 安装,它应该可以工作

我不知道它是如何进入这种奇怪的状态的。 :-/

关于android - Android 启动器 Activity 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36473934/

相关文章:

android - 如何在 Wifi Direct 中创 build 备组所有者?

java - 将 Activity 转换为 fragment 会阻止 RecyclerView onclick 监听器工作

android - 如何在 Android 应用程序的 Activity 之间传递数据?

java - Android - 访问 list 中的提供者标签并更改其属性值

android - flutter 检测指针设备类型

android - 如何强制更新 expo 应用程序

android - 存储用户可访问的配置文件的最佳位置

java - 第二个 Activity 中的输出不起作用

java - 表现形式畸形?

c# - 使MAF AddInProcess.exe "Long Path Aware"