我的应用程序中确实有一个奇怪的错误。 当我直接从操作系统启动应用程序,然后通过任何 Task Killer 从后台将其杀死(这是重现崩溃的少数方法之一)时,我的应用程序崩溃(不介意崩溃,我大致知道为什么 - 类加载器)始终如一 -> 模拟操作系统释放内存并关闭应用程序)并尝试重新启动它。
问题是,如果我使用以下命令通过 adb shell 启动应用程序:
adb shell am start -a android.intent.action.MAIN -n com.my.packagename/myLaunchActivity
我无法重现崩溃。
那么 Android OS 调用应用程序的方式与上述调用方式有什么不同吗?
编辑:添加了 list (只是更改了名称)
<?xml version="1.0" ?>
<manifest android:versionCode="5" android:versionName="1.05" package="com.my.sample" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="7"/>
<application android:icon="@drawable/square_my_logo" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name="com.my.InfoActivity" android:screenOrientation="landscape"></activity>
<activity android:label="@string/app_name" android:name="com.my2.KickStart" android:screenOrientation="landscape"/>
<activity android:label="@string/app_name" android:name="com.my2.Launcher" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/></manifest>
从 adb shell 启动 com.my2.Launcher
最佳答案
我能看到的第一件事是,如果您从启动器图标启动应用程序,Intent 包括类别“android.intent.category.LAUNCHER”,使用 adb shell am
它不会.
此外,当您通过启动器图标启动时,Intent 标志 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
(0x200000) 已设置,在 adb shell
情况下则不是。
不确定其中任何一个是否会对您的崩溃行为产生影响,但它回答了这个问题。
关于android - 从操作系统或从 adb 启动应用程序之间有区别吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11416004/