2012-08-07 77 views
-2

如何驗證應用程序剛剛啓動? 這是正確的方法?如何驗證應用程序剛剛啓動?

if(getIntent().getAction() != null && getIntent().getAction().equals("android.intent.action.MAIN")) { 
+0

它適合你嗎? – 2012-08-07 08:34:29

+0

我在這裏看不到問題... – JoxTraex 2012-08-07 08:35:49

回答

0

,因爲我覺得上述我的方法不能正常工作。

MyApp app = (MyApp)getApplication(); 
if(app.isJustStarted) { 

public class MyApp extends Application { 
public boolean isJustStarted = true; } 

爲問題的解決方案。

0

你總是可以知道它在onCreate()。如果用戶更改了設備的方向,通常您的活動將被系統關閉並重新創建。如果你不希望出現這種情況,考慮增加android:configChanges到你的活動(在AndroidManifest.xml)如下:

<activity 
    android:name="..." 
    android:configChanges="keyboardHidden|orientation" 
    android:label="..." > 
相關問題