Pregunta

I need to open my app using custom protocol like myapp://app I know how to do this in Xcode. Now I'm developing an android app in Xamarin, and I'm wondering is there anyway to do the same in Xamarin.

This is my first Xamarin Android project so I dont know how can I achieve this please help

¿Fue útil?

Solución

as on Android, you should use an Intent Filter to achieve that functionnality, but these are implemented as class attributes in Xamarin.Android, that will be automatically translated to xml in the app manifest at compile time for you.

here's an example to get you going :

[Activity (Label = "MainActivity", MainLauncher = true)]
[IntentFilter (new[]{Intent.ActionMain},
    Categories=new[]{Intent.CategoryLauncher, Intent.CategorySampleCode},
    Icon="@drawable/myicon",
    DataScheme="something",
    DataHost="project.example.com")]
public class MainActivity : Activity
{
}

you can get more details on IntentFilters in the Xamarin docs

watch out if you copy paste their sample, it misses a comma there. so you're no searching for too long like I did ;-)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top