문제

I got two activities.....LoginActivity(Launcher Activity) and MainActivity. When the app is installed and started the LoginActivity is invoked and on entering the username and password, it authenticate from a server and starts the MainActivity. This works fine.

when the app is minimized or Paused using backbutton or homebutton and resumed again i want the app to resume from the MainActivity. How can that be done...I am a beginner...please help!!Thanks.

도움이 되었습니까?

해결책 2

You have to set Global boolean variable and set it to true when you successfully login and check it on resume activity of LoginActivity and start an Intent of MainActivity. Here is the code..

boolean mainActi = false;
mainActi = true;

@Override
protected void onResume() {

super.onResume();

f(mainActi) {
     Intent i1  = new Intent(MainActivity.this,LogIn.class);
     startActivity(i1);
     mainActi = false;
   }
 }

다른 팁

By finishing() your LoginActivity(Launcher Activity) , and storing your data ( LoginActivity ) in Bundle argument in Bundle .... and restoring that data in onResume() of MainActivity with the help of Bundle of argument .

Edited :

Create a global_Bundle_Argument LoginActivity .

Bundle bun ;

and , inside onCreate put this.bun = bun ; bun.putString(key, value) ;

send this bundle argument with intent : intent.putExtra(name, value) ;

and get this bundle argument in MainActivity() ; Bundle bun = intent.getBundleExtra(name) .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top