Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble Intent Error
    primarykey
    data
    text
    <p>I have a problem regarding the code below, I have two buttons on my welcome screen. Each of the button links to different page, am I using the wrong code? Can you all guide me and correct me?? I am new android app development.</p> <pre><code>package com.example.testing; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class WelcomeActivity extends Activity implements OnClickListener { private Boolean firstRun; //private Boolean accountRun; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.welcome); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if(sp.getBoolean("firstRun", true)){ PreferenceManager.setDefaultValues(this, R.xml.preferences, true); firstRun = true; SharedPreferences.Editor editor = sp.edit(); editor.putBoolean("firstRun", false); editor.commit(); } else { firstRun = false; } this.initViews(); } private void initViews(){ Button btnAccount = (Button)this.findViewById(R.id.btnAccount); btnAccount.setOnClickListener(this); Button btnContinue = (Button)this.findViewById(R.id.btnContinue); btnContinue.setOnClickListener(this); } @Override public void onClick(View arg0) { Intent i = new Intent(this, testingquestion1.class); i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.putExtra("firstRun", firstRun); startActivity(i); Intent h = new Intent(this, testingquestion2.class); //h.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); //i.putExtra("firstRun", firstRun); startActivity(h); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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