2016-07-01 209 views

回答

0

做一個靜態函數,以您的公用事業類像 -

public static void launchForgroundActivity(Context context){ 
    Intent intent = new Intent(context, ForgroundActivity.class); 
    context.startActivity(intent); 
} 

在每一次活動都保持標誌會像背景 -

boolean isBackground = false; 

public void onStop(){ 
    super.onStop(); 
    isBackground = true; 
} 

現在在onStart,如果檢查的IsBackground值是true,則啓動forground活動。

public void onStart(){ 
    super.onStart(); 
    if(isBackground) 
     Utility.launchForgroundActivity(getApplicationContext()); 
} 

希望這將有助於:)

+0

它的工作原理。感謝您拯救我的一天:) @Neo –

+0

@Pooja請接受最好的答案:) – Neo

相關問題