Reputation: 1796
As the title states I am trying to start an Android Xamarin app from another (native) Android app and the packageManager.queryIntentActivities
query is failing. So I am probably doing something wrong on the either the Android app side, or more likely on the Xamarin side.
Here is the class definition on the Xamarin
side:
using Android.OS;
namespace DeepLinkTest.Droid
{
[Activity(Label = "DeepLinkTest", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
DataScheme = "*",
DataHost = "deeplinktest",
DataPath = "MyAppDidComplete",
Categories = new[] { Android.Content.Intent.CategoryDefault })]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
}
}
From what I have read the intent
is places as shown above the MainActivity
.
And here is the call I am making (an uri based call - maybe that is the problem?) in the native Android App:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("deeplinktest://MyAppDidComplete/somedata"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Verify it resolves
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
// Start an activity if it's safe
if (isIntentSafe) {
startActivity(intent);
}
Upvotes: 1
Views: 267
Reputation: 95646
You've confused the HOST and SCHEME of the URL. Your URL:
"deeplinktest://MyAppDidComplete/somedata"
breaks down as follows:
Your IntentFilter
is set to match:
You should modify the one or the other so that they match.
Upvotes: 1