我正面临一种奇怪的行为。Activity B
我从我的内心开始一个新MainActivity
的
Intent mIntent = new Intent(this, ActivityB.class);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //tried addFlags as well
startActivity(mIntent);
突然(10-45秒之间),突然MainActivity
又开始了,没有任何理由。在 Logcat 中,我看到MainActivity
正在再次创建(甚至没有恢复),并收到了意图android.intent.action.MAIN
更奇怪的是,如果我ActivityC
以同样的方式启动另一个,它工作正常并且不会跳回 MainActivity...
有人有什么想法吗?
日志猫
05-21 15:35:13.897: D/dalvikvm(14312): GC_FOR_ALLOC freed 8K, 6% free 18231K/19356K, paused 33ms, total 33ms
05-21 15:35:13.936: D/dalvikvm(14312): GC_CONCURRENT freed 17K, 6% free 18213K/19356K, paused 2ms+5ms, total 33ms
05-21 15:35:14.108: D/dalvikvm(14312): GC_FOR_ALLOC freed 71K, 6% free 18235K/19356K, paused 25ms, total 26ms
05-21 15:35:14.123: I/dalvikvm-heap(14312): Grow heap (frag case) to 27.696MB for 10342416-byte allocation
05-21 15:35:14.155: D/dalvikvm(14312): GC_FOR_ALLOC freed 0K, 4% free 28335K/29460K, paused 24ms, total 24ms
05-21 15:35:14.178: D/dalvikvm(14312): GC_CONCURRENT freed 1K, 4% free 28334K/29460K, paused 3ms+5ms, total 28ms
05-21 15:35:14.780: I/Choreographer(14312): Skipped 58 frames! The application may be doing too much work on its main thread.
05-21 15:35:23.623: D/dalvikvm(14312): GC_FOR_ALLOC freed 5879K, 18% free 28729K/34636K, paused 35ms, total 36ms
05-21 15:36:00.037: D/dalvikvm(14312): GC_CONCURRENT freed 6198K, 18% free 29094K/35320K, paused 7ms+14ms, total 92ms
//above, is the last result, before MainActivity is starting again
05-21 15:37:28.498: I/MainActivity(15078): onCreate() -> android.intent.action.MAIN
05-21 15:37:28.623: D/dalvikvm(15078): GC_FOR_ALLOC freed 65K, 2% free 8901K/8996K, paused 44ms, total 45ms
清单.xml
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
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=".ActivityB"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait">
</activity>