I currently struggle to have YouTube links to be opened in the browser or the YouTube app. I am aware of the new Package visibility in Android 11 and implemented it this way.
MyClass.java$myMethod
String ytLink = "https://www.youtube.com/watch?v=Hp_Eg8NMfT0"
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(ytLink));
if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent);
}
AndroidManifest.xml
<manifest>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
</manifest>
However the intent.resolveActivity returns null... Every other link I've tried returns a ComponentName so the Intent can be started...
Do you have any clue?
Thanks in advance ;)