Wednesday, 19 September 2012

Android Quiz Game App Source Code

Keywords: Free Android quiz game source code, Project or code to create make android based quiz game download

Note: Updated version of Android App Quiz Game source code is available at Android Quiz Game Using XmlPullParser.

In this article, I am sharing source code to create android based quiz game. One can use this code to create their own personal quiz game. It was very interesting developing a QuoteQuiz app (Search for QuoteQuiz in Google play or Androidzoom.com) for android device.

As, I was new to android development, I had developed a simple quiz game app using only activities with basic skill of coding. There are many way, depending on developer, on how to develop it. In this app, I had only used activities and Xml files. No SQLite is used to save any data. Data between activities are passed using Intent.

Given below image are a glance of QuoteQuiz app. Subscribe to our newsletter to get the source code.





QuoteQuiz is created in very simple way so that beginner can learn it easily. Check out advance version of quiz on google play under SmakAndApp publisher.

Few code snippet used in coding.

Each Activity represent as new question.


@Override
 public void onCreate(Bundle savedInstanceState)
 {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.questone);
     
        Button NextButton = (Button) findViewById(R.id.id_btn_Next1);
        NextButton.setOnClickListener(this);
       
        TextView tvScore = (TextView) findViewById(R.id.id_tv_score1);
        tvScore.setText("Score : "+ 0);
    }

  @Override
 public void onClick(View v)
 {
  // TODO Auto-generated method stub
  int cnt = 0;
  RadioButton rdb1 = (RadioButton) findViewById(R.id.id_rbtn_Quest1_1);
  RadioButton rdb2 = (RadioButton) findViewById(R.id.id_rbtn_Quest1_2);

  if(rdb1.isChecked() || rdb2.isChecked() )
  {
   if(rdb1.isChecked())
   {
    cnt++;
 
   }
  Intent i = new Intent(this,QuestTwoActivity.class);
  i.putExtra("score",cnt);
  startActivity(i);
  finish();
  }

 }

Data sent between activities is shown below:

Intent i = new Intent(this,QuestTwoActivity.class);
i.putExtra("score",cnt);
"score" is key and "cnt" is value.



cnt = getIntent().getIntExtra("score",0);

"score" is key and 0 is default value i.e. if no data is passed it will assign 0.