Home:ALL Converter>navigation component with navigation view android

navigation component with navigation view android

Ask Time:2020-08-14T19:27:25         Author:Yaffa Harari

Json Formatter

I am trying work with navigation component.
currently I have navigation view with menu.
I implement onNavigationItemSelected in navigation view and detect click by item.getItemId() when there is clicks on specific items, it do something that not navigate to fragment. for example:

 switch (item.getItemId()) {
        case R.id.nav_share:
            Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            String shareBody = "shae StayTuned with friends bla bla bla and we can put app url in the google play " +
                    "if we don't will be sdk";
            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
            startActivity(Intent.createChooser(sharingIntent, "Share via"));
            break;
        case R.id.nav_disconnect_user:
            FirebaseAuth.getInstance().signOut();
            break;
    }

how I can achieve that with navigation component? thanks!

Author:Yaffa Harari,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/63411881/navigation-component-with-navigation-view-android
yy