How to recover several actions from one activity to another?

2

How to send url from one activity to another with different click actions (multiple buttons)? I tried to use intent.putextra but I can not resort to the urls of the other buttons, in the case I am using two activities the second this with webview I ran with loadurl, but as I said I can only make a button work, and I do not know how to receive the others in the same activity.

submitting like this:

Home.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View view) {
  Intent intent = new Intent(inicio.this,INSMainActivity.class);
  intent.putExtra("hiphop", "https://m.youtube.com/channel/UCUnSTiCHiHgZA9NQUG6lZkQ");
                startActivity(intent);
            }
        });

receiving:

String url = getIntent().getExtras().getString("hiphop");
    youtubeView = (WebView) findViewById(R.id.youtube_view);
    youtubeView.loadUrl(url);

As seen in the code I'm trying to load genres from the first activity.

    
asked by anonymous 14.08.2017 / 05:27

1 answer

1

I'm using Intent in my project and it's working normal, at the time of receiving I'm getting like this:

Create the variable String url together with the class and then the onCreate

Bundle extras = getIntent().getExtras();
        if(extras != null)
        {
            url= extras.getString("hiphop");
        }

Then you can continue the code

youtubeView = (WebView) findViewById(R.id.youtube_view);
    youtubeView.loadUrl(url);
    
16.08.2017 / 12:51