How to recover several actions from one Active to another?

Asked

Viewed 299 times

2

How do I send an Activity url to another with different click actions (multiple buttons)? I tried to use intent.putextra but I can’t recur the urls of the other buttons, in case I’m using two Activity the second this with webview ran with loadurl, but as I said I can only make it work one button, and I don’t know how to receive others in the same Activity.

thus sending:

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 am trying to load genres from the first Activity.

1 answer

1

I’m using the Intent in my project and is working normal, at the time of receiving I am receiving so:

Create the variable String url together with the class and then in 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);
  • I’ll test like this

  • @Anything just say what comes up that I’m trying to check

Browser other questions tagged

You are not signed in. Login or sign up in order to post.