0

My problem is exactly like this link but it's not in android.

I have one button on a layout and two buttons on an another one. On my application, ClickScreen activity can be triggered by either FirstCase activity or SecondCase activity.

I tried to make a conditional statement on my ClickScreen for which activity is triggered but couldn't handle it. I don't want to create two more classes to do this since it's not an efficient technique.

private void goTo2ndPage() {
    Intent i3 = new Intent(this, ClickScreen.class);
    startActivity(i3);
}

public class ClickScreen extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.click_screen);

    }
}
Cem
  • 13
  • 8
  • What you want to do is let ClickScreen.class know from which activity it started? And then show it in a textView? – Kwnstantinos Nikoloutsos Apr 28 '19 at 14:19
  • Yes but it's more like which button is clicked because there are two activites with three buttons totally and text like message1.setText("Button 1") – Cem Apr 28 '19 at 14:24
  • What you actually want is a way to add some extra data in you intents. Take a look at this post : https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application – Kwnstantinos Nikoloutsos Apr 28 '19 at 14:45
  • I mean it's more like which button is clicked also because one of the activity layout has two buttons. – Cem Apr 28 '19 at 14:46
  • Yes you can pass the data(which data was clicked) in your intent and then let the other activity know what you want. – Kwnstantinos Nikoloutsos Apr 28 '19 at 14:47
  • Thank you, it solved my problem. I don't know java or other languages a lot, only familiar with coding algorithm but trying to learn by searching and practice. I don't understand why some people down voted my question, I just didn't think in that way to do it. – Cem Apr 28 '19 at 16:13
  • @Kwnstantinos Nikoloutsos, can you please post your comment as an answer? So I can mark it as accepted. Thanks again. – Cem Apr 28 '19 at 16:19
  • Don't worry buddy, the goal is to learn. Ignore those who think that your question is not good. "Even professional was once a beginner" – Kwnstantinos Nikoloutsos Apr 28 '19 at 19:46

1 Answers1

0

As we discussed in comments. It looks like what you really want is to add extra data in your intent so that Started Activity can get it and act accordingly.

Check out this post !

Kwnstantinos Nikoloutsos
  • 1,832
  • 4
  • 18
  • 34