-2
如何驗證應用程序剛剛啓動? 這是正確的方法?如何驗證應用程序剛剛啓動?
if(getIntent().getAction() != null && getIntent().getAction().equals("android.intent.action.MAIN")) {
如何驗證應用程序剛剛啓動? 這是正確的方法?如何驗證應用程序剛剛啓動?
if(getIntent().getAction() != null && getIntent().getAction().equals("android.intent.action.MAIN")) {
,因爲我覺得上述我的方法不能正常工作。
MyApp app = (MyApp)getApplication();
if(app.isJustStarted) {
和
public class MyApp extends Application {
public boolean isJustStarted = true; }
爲問題的解決方案。
你總是可以知道它在onCreate()
。如果用戶更改了設備的方向,通常您的活動將被系統關閉並重新創建。如果你不希望出現這種情況,考慮增加android:configChanges
到你的活動(在AndroidManifest.xml
)如下:
<activity
android:name="..."
android:configChanges="keyboardHidden|orientation"
android:label="..." >
它適合你嗎? – 2012-08-07 08:34:29
我在這裏看不到問題... – JoxTraex 2012-08-07 08:35:49