Skip to content

Instantly share code, notes, and snippets.

@S64
Last active August 22, 2016 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save S64/c37c4b9742477ef3a4ff337b7dfbd458 to your computer and use it in GitHub Desktop.
Save S64/c37c4b9742477ef3a4ff337b7dfbd458 to your computer and use it in GitHub Desktop.
[Activity(Label = "AnotherImplicitActivity")]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "https",
DataHost = "example.wantedly.com",
DataPathPattern = PATH_PATTERN_1
)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "wtd-example",
DataHost = "example_content",
DataPathPattern = PATH_PATTERN_2
)]
public class AnotherImplicitActivity : Activity
{
public const string PATH_PATTERN_1 = "/example_content/.*";
public const string PATH_PATTERN_2 = "/.*";
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Android.Net.Uri uri;
if (this.Intent != null && (uri = this.Intent.Data) != null)
{
var m1 = Regex.Match(uri.Path, PATH_PATTERN_1);
var m2 = Regex.Match(uri.Path, PATH_PATTERN_2);
if (m1.Success)
{
UpdateContent(uri.PathSegments[1]); // TODO
} else if (m2.Success)
{
UpdateContent(uri.PathSegments[0]); // TODO
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment