我面临一种奇怪的行为。我从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 ......
任何想法?
logcat的
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
的Manifest.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>
答案 0 :(得分:0)
删除launchmode或将其添加到所有活动中,你总是将mainactivity推到其他活动之上 编辑:没看到你做了^^
答案 1 :(得分:0)
veeery很奇怪..最后我发现,我正在使用CustomTextView
,它正在将文本倾斜到一个大位图...我删除了这个由于另一个解决方案,现在{{1不再开始......似乎我的View因某种原因被杀了,但我的Logcat没有任何错误......至少它现在正在工作....