Search code examples
androidandroid-navigationandroid-architecture-navigation

Android navigation component open url


I have simple code that opens URL in a browser:

startActivity(Intent(
    Intent.ACTION_VIEW, Uri.parse(resources.getString(R.string.application_url))
))

How can I convert this to the navigation component item?

Do I need to build custom navigator for this, or navigation component has something built in for such case?


Solution

  • I figured it out, for this simple case custom navigator is not needed all you need is to create navigation endpoint:

    <activity
        android:id="@+id/navigation_endpoint_id"
        app:action="android.intent.action.VIEW"
        app:data="@string/application_url"/>