Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid on finish() recreates Activity
    primarykey
    data
    text
    <p>Strange things happens if I try to finish activity. After calling for the first time activity <em>finish</em> method - activity re-creates.</p> <pre><code>BroadcastReceiver requestReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { long resultRequestId = intent.getLongExtra(DVSServiceHelper.EXTRA_REQUEST_ID, 0); if(BuildConfig.DEBUG) Log.d(TAG, "received request id: "+ resultRequestId +", current request id: "+ requestId); if (resultRequestId == requestId) { int resultCode = intent.getIntExtra(DVSServiceHelper.EXTRA_RESULT_CODE, 0); Logger.debug(TAG, "result code: "+ resultCode); switch(resultCode) { case HttpsURLConnection.HTTP_OK: //Dummy intent Intent in = new Intent(); Logger.debug(TAG, "HTTP OK"); //User logged in successfuly. Finish Login activity LoginActivity.this.setResult(AuthorizationManager.LOGIN_SUCCESS, in); Logger.debug(TAG, "setting result..."); LoginActivity.this.finish(); Logger.debug(TAG, "finishing..."); break; ... </code></pre> <p>Activity onCreate method:</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_activity); Logger.debug(TAG, "[onCreate]"); ... </code></pre> <p><strong>LogCat output</strong></p> <p>on first attempt:</p> <pre><code>08-14 17:46:00.917: D/(7975): [LoginActivity] result code: 200 08-14 17:46:00.917: D/(7975): [LoginActivity] HTTP OK 08-14 17:46:00.917: D/(7975): [LoginActivity] setting result... 08-14 17:46:00.937: D/(7975): [LoginActivity] finishing... 08-14 17:46:00.977: D/(7975): [LoginActivity] [onCreate] </code></pre> <p>on seconds attempt:</p> <pre><code>08-14 17:50:25.437: D/(7975): [LoginActivity] result code: 200 08-14 17:50:25.437: D/(7975): [LoginActivity] HTTP OK 08-14 17:50:25.437: D/(7975): [LoginActivity] setting result... 08-14 17:50:25.537: D/(7975): [LoginActivity] finishing... 08-14 17:50:25.567: D/(7975): [MainActivity] [onActivityResult] 08-14 17:50:25.567: D/(7975): [MainActivity] [onActivityResult] 08-14 17:50:25.567: D/(7975): [MainActivity] [onResume] </code></pre> <p><strong>EDITED</strong></p> <p><strong>MainActivty</strong></p> <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) { Logger.debug(TAG, "[onActivityResult]"); if(AuthorizationManager.REQUEST_LOGIN == requestCode) { if(AuthorizationManager.LOGIN_FAILED == resultCode) { Logger.debug(TAG, "Login failed!"); Intent login = new Intent(DVSApplication.getContext(), LoginActivity.class); startActivityForResult(login, AuthorizationManager.REQUEST_LOGIN); } } } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Logger.debug(TAG, "[onCreate]"); //if user isn't saved crediantials - show log in activity if(!AuthorizationManager.getManager(getApplicationContext()).isLoggedIn()) { Logger.debug(TAG, "[onCreate] user is not logged in!"); Intent login = new Intent(DVSApplication.getContext(), LoginActivity.class); startActivityForResult(login, AuthorizationManager.REQUEST_LOGIN); } ... } protected void onResume() { super.onResume(); Logger.debug(TAG, "[onResume]"); //if user isn't saved crediantials - show log in activity if(!AuthorizationManager.getManager(getApplicationContext()).isLoggedIn()) { Logger.debug(TAG, "[onResume] User is not logged in!"); Intent login = new Intent(DVSApplication.getContext(), LoginActivity.class); startActivityForResult(login, AuthorizationManager.REQUEST_LOGIN); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload