2016-05-24 5 views
0

私は「A」というアクティビティと「B」という別のアクティビティを持つアプリを開発しています。私は "A"から "B"の間を移動する意図を使用しましたが、私のアプリがバックグラウンドになると、Intentはまだ動作します。
アプリが一時停止状態になると、「A」から「B」への移動が停止します。どうすればいいですか?アクティビティがアンドロイドで一時停止状態になったときにインテントを停止する方法はありますか?

public class CSplashScreen extends AppCompatActivity { 
// Splash screen timer 
private static final int m_n_SplashTimeOut = 4000; 
private ImageView splash_image; 
private boolean isConnected; 
private static CLoginSessionManagement s_oCloginSession;// refernce of loginsession management 
public void onAttachedToWindow() { 
    super.onAttachedToWindow(); 
    Window window = getWindow(); 
    window.setFormat(PixelFormat.RGBA_8888); 
} 
@Override 
protected void onCreate(@Nullable Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.splash); 
    if (NetworkUtil.isConnected(getApplicationContext())){ 

    }else { 
     CSnackBar.getInstance().showSnackBarError(findViewById(R.id.mainLayout), "No internet connection available", getApplicationContext()); 
    } 
    init();//initialize controls 

} 
private void init() {// initialize controls 

    Animation animation = null; 
    splash_image = (ImageView) findViewById(R.id.splash_image); 
    animation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out); 
    animation.setDuration(1500); 
    splash_image.startAnimation(animation); 
    new Handler().postDelayed(new Runnable() { 
     //   This method will be executed once the timer is over 
     @Override 
     public void run() { 
      Intent i = new Intent(CSplashScreen.this, CMainActivity.class); 
      startActivity(i); 
     } 
    }, m_n_SplashTimeOut);// spalsh screen timing 


} 

}あなたが.. 'isPauch' のような旗を持ってonPause(中でそれが本当作る)とonResumeで、それは偽にすることができ

+0

あなたは、AからBへのナビゲーションがあなたのアプリでユーザー生成されていないことを意味しますか?それはAsyncTaskからですか? –

+0

この「意図」をいつどこで使用しますか? –

+0

これをチェックしてくださいhttp://stackoverflow.com/questions/5446565/android-how-do-i-check-if-activity-is-running –

答えて

0
@Override 
public void run() { 
    if (!isFinishing()) { 
     startActivity(new Intent(CSplashScreen.this, CMainActivity.class)); 
    } 
} 
+0

このコードを説明できますか... – Rajesh

+0

(!isFinishing)メソッド – Rajesh

+0

@Rajeshこのソリューションを試しましたか? –

0

():ここで

コードです。 flagがfalseかどうかを確認し、他のアクティビティに移動します。

+0

ここで確認するには、 – Rajesh

+0

を作成してください。 – Shubham

関連する問題