我希望我的應用只在應用第一次啓動時纔開始活動。 任何人有任何想法?僅啓動一次活動
我發現這個,但它只顯示黑屏。
public class WhatsNew extends Activity {
public static final String PREFS_NAME = "MyPrefsFile";
protected void onCreate(Bundle state){
super.onCreate(state);
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
boolean dialogShown = settings.getBoolean("dialogShown", false);
if (!dialogShown) {
// AlertDialog code here
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("dialogShown", true);
editor.commit();
}
}
}
它顯示黑屏,因爲沒有加載沒有佈局(即沒有'setContentView'),所以它顯示一個空的窗口。 – Dave