Opening external site in android studio within a list item

0

I need to open an external link, for example:

https:www.google.com.br

But it should be within a menu list litem (side menu). To open the fragments I use the position of the item, there are 7 positions mentioned below.

@Override
public void onNavigationDrawerItemSelected(int position) {
    switch (position) {

    case 0:
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, new FragmentListaRestaurantes_())
                .commit();
        break;

    case 1:
        getSupportFragmentManager().beginTransaction().addToBackStack(BACKSTACK)
                .replace(R.id.container, new FragmentFavoritos_())
                .commit();
        break;

    case 2:
        getSupportFragmentManager().beginTransaction().addToBackStack(BACKSTACK)
                .replace(R.id.container, new FragmentMeusPedidos_())
                .commit();
        break;

    case 3:
        getSupportFragmentManager().beginTransaction().addToBackStack(BACKSTACK)
                .replace(R.id.container, new FragmentMeusDados_()).commit();
        break;
    case 4:
        getSupportFragmentManager().beginTransaction().addToBackStack(BACKSTACK)
                .replace(R.id.container, new FragmentIndique()).commit();
            break;
    case 5:
            getSupportFragmentManager().beginTransaction().addToBackStack(BACKSTACK)
                    .replace(R.id.container, new FragmentIndique()).commit();
            break;
    case 6:
        sair();
        break;
    }
}

His position is 5.

My question is the following, I need to send it to any fragment and redirect it or I can define the click directly from this case, calling a function that does this work?

And how should I program this?

    
asked by anonymous 15.05.2017 / 15:50

1 answer

1

Do you want to send it to an external browser?

Do as follows:

case 5:
   String url = "http://www.google.com.br";
   Intent i = new Intent(Intent.ACTION_VIEW);
   i.setData(Uri.parse(url));
   startActivity(i);
break;
    
15.05.2017 / 15:54