Note that there are some explanatory texts on larger screens.

plurals
  1. POOnCreate method keeps getting called repeatedly
    primarykey
    data
    text
    <hr> <p><strong>Update:</strong> Thank you all for attempting to help me solve this bug. I am still unsure as to the cause, I was able to roll back to a previous commit and continue development from there. This previous commit did show the same bug, however after I commented out <code>button.performClick()</code> it went away. Strangely, this does not work on the most recent commit. </p> <p>I still do not understand this bug and would appreciate any more assistance in helping determine the root cause. My greatest fear would be to inadvertently re-introduce it.</p> <hr> <p>I have the most crazy error I have ever seen.</p> <p>The OnCreate method is being called over and over again, freezing my application and giving me a slight flicker. The only solution is then to exit to the home screen and force quit the application from the settings menu.</p> <p>Here is what is happening in detail:</p> <ol> <li>Application starts (Main Activity)</li> <li>Main Activity calls the Second Activity</li> <li>Second Activity calls onCreate, sets up as normal</li> <li>Second Activity randomly decides to exit onCreate &lt;-- I think this what's happening</li> <li>Second Activity's onCreate gets called again. It doesn't ever return to the Main Activity.</li> </ol> <p>I have run a debugger, it appears that the second activity successfully completes the onComplete/onResume sequence, then decides to exit and restart.</p> <p>Has anybody ever heard of this behavior before? </p> <p>I haven't noticed any exceptions being thrown. Also, in the course of debugging, I did go ahead and check those locations that you see as silent fail. (this is the older code before I littered it with print statements)</p> <p><strong>UPDATE:</strong> When attempting to stop the process, I must turn on airplane mode. This means it has something to do with this code block (Second Activity)</p> <pre><code>else if (Network.haveNetworkConnection(Login.getContext()) &amp;&amp; Login.checkClientId()) {...} </code></pre> <p><strong>With no internet, it will hit the else statement and does not display this behavior.</strong></p> <p><strong>CODE:</strong></p> <p>onResume() of the Main Activity, where I call the Second Activity:</p> <pre><code> @Override public void onResume() { super.onResume(); //Check If logged in, else go to login page Login.setContext(getApplicationContext()); //Reset Notification Number GCMIntentService.cancelNotifications(); /** GO TO LOGIN **/ if(!Login.isLoggedIn()) { //If user is not logged in, open login page System.out.println("RESUMING MAIN AND STARTING LOGIN INTENT"); Intent intent = new Intent(ActivityMain.this, ActivityLogin.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { Login.setupStuffOnce(); Event.pullEvents(); //Get New Events //Update ListView updateMainFeed(); } } </code></pre> <p>This is the Second Activity:</p> <pre><code>public class ActivityLogin extends Activity { private String postData; //private Context c; //final Timer timer = new Timer(); //Facebook Stuff private Facebook facebook = new Facebook(Config.FBAPPID); private AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook); //Layout Stuff EditText username, password; Button loginButton, signupButton; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Open Database Login.setContext(getApplicationContext()); Database.open(getApplicationContext()); } /* * @Override public void onPause() { s } */ @Override public void onResume() { super.onResume(); // shouldn't put here but oh well init(); //If coming from ActivitySignup if(Transfer.username != null) { username.setText(Transfer.username); password.setText(Transfer.password); Transfer.password = null; Transfer.username = null; loginButton.performClick(); } } public void init() { Login.getUserLoggedIn(); if (Login.isLoggedIn()) { //Do Any Additional Setup Login.setupStuffOnce(); // If user is logged in, open main Intent intent = new Intent(ActivityLogin.this, ActivityMain.class); //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else if (Network.haveNetworkConnection(Login.getContext()) &amp;&amp; Login.checkClientId()) { // Else, Make User Login // Inflate Login and Present Website String clientid = Login.getClientId(); System.out.println("clientid:" + clientid); //System.exit(0); postData = "mobile=1&amp;client_id="+Login.getClientId(); // Inflate the view setContentView(R.layout.activitylogin3); username = (EditText) findViewById(R.id.username); password = (EditText) findViewById(R.id.password); //Inflate the Button loginButton = (Button) findViewById(R.id.loginButton); signupButton = (Button) findViewById(R.id.signupButton); signupButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ActivityLogin.this, ActivitySignup.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } }); loginButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { int res = Login.sendLogin(username.getText().toString(), password.getText().toString()); if(res == 202) { //Login Successful //Check if facebooked. if(Login.isFacebooked()) { //Just go to main Intent intent = new Intent(ActivityLogin.this, ActivityMain.class); //Are these flags necessary? //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { //Go to facebook login page //Intent intent = new Intent(ActivityLogin.this, ActivityFBLogin.class); //startActivity(intent); //Login via Facebook doFacebook(); } } else { System.out.println("Login Failed: "+res); if(res == 405) { Toast.makeText(getApplicationContext(), "Incorrect Username/Password", Toast.LENGTH_SHORT).show(); password.setText(""); } else Toast.makeText(getApplicationContext(), "Network Error", Toast.LENGTH_SHORT).show(); //Not entirely true in all cases i think } /*Login.getUserLoggedIn(); if(Login.isLoggedIn()) { Intent intent = new Intent(ActivityLogin.this, ActivityMain.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { Toast.makeText(getApplicationContext(), "Please Login Above", Toast.LENGTH_SHORT).show(); }*/ } }); } else { // Not Logged In and No Internet Access setContentView(R.layout.activitylogintext); EditText text = (EditText) findViewById(R.id.text); text.setText("No Internet Connection Detected\n requires internet to login"); Button button = (Button) findViewById(R.id.refreshButton); button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { //Login.getUserLoggedIn(); if(Network.haveNetworkConnection(Login.getContext())) { Intent intent = new Intent(ActivityLogin.this, ActivityLogin.class); //intent.setFlags(); startActivity(intent); } else { Toast.makeText(getApplicationContext(), "No Internet Access Detected", Toast.LENGTH_SHORT).show(); } } }); } } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); facebook.authorizeCallback(requestCode, resultCode, data); } public void doFacebook() { facebook.authorize(this, Config.facebookPermissions, new DialogListener() { @Override public void onComplete(Bundle values) { /*SharedPreferences.Editor editor = state.edit(); editor.putString("access_token", facebook.getAccessToken()); editor.putLong("access_expires", facebook.getAccessExpires()); editor.commit(); */ //Input into database Login.saveAccessToken(facebook.getAccessToken()); Login.setFB(facebook.getAccessToken()); //Login.sendAccessToken(facebook.getAccessToken()); //Intent into Main Activity Intent intent = new Intent(ActivityLogin.this, ActivityMain.class); //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } @Override public void onFacebookError(FacebookError error) { Toast.makeText(getApplicationContext(), "Error: "+error.getErrorType(), Toast.LENGTH_SHORT).show(); } @Override public void onError(DialogError e) { Toast.makeText(getApplicationContext(), "Error: "+e.getMessage(), Toast.LENGTH_SHORT).show(); } @Override public void onCancel() {} }); } public boolean checkForUserID(Context c) { try{ String res = Network.getUrl("www.website.com/mobile.php?got_user=1&amp;client_id="+Login.getClientId()); JSONObject json = JSON.constructObject(res); if(JSON.handleCode(json)) { if(json.getString("type").equals("userid")) { Login.setLogin(json.getString("data")); return true; } } } catch(Exception e) { //Silent Fail } return false; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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