Hey guys I am trying to create a game where when a condition is met the the Activity is called and now runs level 2 conditions, and so on as the levels increment. The problem is that the level integer which stores the level always resets to the initialised value, I basically want to call the intent if the level up condition is met, reload the activity and increment the level integer.

I cannot figure out how to do this, here is my activity which I want to call:

package com.deucalion0;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class FirstOneActivity extends Activity {
    /** Called when the activity is first created. */
	MediaPlayer  ourSong;
	int counter;
	Button add;
	Thread timer;
	TextView display;
	TextView lvl;
	int level = 1;
	int time;

    public void onCreate(Bundle savedInstanceState) {
        ourSong = MediaPlayer.create(FirstOneActivity.this, R.raw.click);
        counter = 0;
        add = (Button) findViewById (R.id.bAdd);
        display = (TextView) findViewById (R.id.tvDisplay);
        lvl = (TextView) findViewById (R.id.lvldisplay);
        add.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				// TODO Auto-generated method stub
				display.setText("Your total is "+ counter);
				if(counter ==1)

    	 timer = new Thread(){
			public void run(){
				}catch(InterruptedException e){
    public void test(){
   	 if(counter>= 10 && level == 1 || counter>= 15 && level == 2)
			Intent openSplash = new Intent("com.deucalion0.FIRSTONE");
		 else if(counter<10 && level == 1 || counter< 15 && level == 2){
			Intent openNext = new Intent("com.deucalion0.NEXT");
    public void set(){
    	  if(level == 1)
  		{	lvl.setText("Level is "+ level);
  			time = 5000;
  		else if (level == 2)
  		{lvl.setText("Level is "+level);
  			time = 5000;

I would appreciate any help at all.

Many thanks!

Just create a new constructor for your activity that takes integer as parameter. Then when calling on the activity past new level value as parameter of call

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.