Android app not visible when share link from youtube

Viewed 81

The problem is as follow:

I read the android documentation and as far as I found in other topics that the share link from YouTube is with tag "text/plain". Also I found different questions posted in SO but I my app is still not visible to the YouTube share.

I am using the following filters in my manifest

<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
  <data android:mimeType="*/*"/>
</intent-filter>

What is the reason for not seeing my app in the share list?

1 Answers

Where in the manifest are you putting the intent filter? In native Android, it would go in an <activity> element in the manifest, but in Xamarin.Android Activities are not declared directly on the manifest but instead in C# Attributes. This is because Xamarin.Android creates wrappers that add a hash before the activity name, so you need to declare intent filters using an attribute on the activity class, not in the manifest as you do not know what the actual final, compiled activity name will be. More info here: https://docs.microsoft.com/en-us/xamarin/android/platform/android-manifest

In a template Xamarin.Android app, you will see an [Activity(...)] attribute that defines the Label, whether the activity is a main launcher, etc. At compile time, this will generate the necessary Android Manifest <activity> element. You can add intent filters this way as well using the [IntentFilter(...)] attribute, so try adding the following above the Activity class that you want to handle the intent:

[IntentFilter (new[] { Intent.ActionSend }, Categories = new[] {Intent.CategoryDefault }, DataMimeType = "text/plain")]

In context:

[Activity(Label = "App1", MainLauncher = true, Icon = "@mipmap/icon")]
[IntentFilter (new[] { Intent.ActionSend }, Categories = new[] {Intent.CategoryDefault }, DataMimeType = "text/plain")]
public class MainActivity : Activity 
{
    ...
}

Again, at compile time, the above will generate the <intent-filter> element in the Android Manifest. This generated manifest will be in the obj folder of the project, you will not see these generated entries when you open the AndroidManifest.xml file that is in the app project itself.

Related