In my app, there are so many activities which are referred to as levels. And one activity is Reward activity. when i win level-1, reward activity opens. Now i want to replay the level-1. For this i have used getExtra(). My app crashes when i click the replay button.
Houselevel1.java
 public void getReward(){
    if(count == 3) {
        Intent intent = new Intent("com.creatives.arfa.revealthesecretsgame.Reward");
        intent.putExtra("activity", "level1");
        startActivity(intent);
    }
}
HouseLevel2.java
    public void getReward(){
    if(count == 3) {
        Intent intent = new Intent("com.creatives.arfa.revealthesecretsgame.Reward");
        intent.putExtra("activity", "level2");
        startActivity(intent);
    }
}
Reward.java
  public void replayLevel() {
    replay = (ImageButton) findViewById(R.id.replay);
    Intent intent= getIntent();
    activity = intent.getStringExtra("activity");
    replay.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View paramView) {
            if(activity.equals("level2")){
                Intent intent = new Intent("com.creatives.arfa.revealthesecretsgame.HouseLevel2");
                startActivity(intent);
            }
            if(activity.equals("level1")){
                Intent intent = new Intent("com.creatives.arfa.revealthesecretsgame.Houselevel1");
                startActivity(intent);
            }
        }
    });
}
 
     
    