Im trying to launch an app that I've created from another app that Im working on right now. The thing is I've been searching throught the internet and found something but it did not work so Im seeking help in here.
This is what I've done on the app I want to launch from :
On my xaml.cs :
public async void GoToDigDitApp(object sender, EventArgs e)
{
var appname = "digdit://";
var result = await DependencyService.Get<IAppHandler>().LaunchApp(appname);
}
I created an Interface:
public interface IAppHandler
{
Task<bool> LaunchApp(string uri);
}
In the Android project:
[assembly: Dependency(typeof(OpenAppAndroid))]
namespace SupervisingApp.Droid
{
[Activity(Label = "OpenAppAndroid")]
public class OpenAppAndroid : Activity, IAppHandler
{
public Task<bool> LaunchApp(string uri)
{
bool result = false;
try
{
var aUri = Android.Net.Uri.Parse(uri.ToString());
var intent = new Intent(Intent.ActionView, aUri);
Android.App.Application.Context.StartActivity(intent);
result = true;
}
catch (ActivityNotFoundException)
{
result = false;
}
return Task.FromResult(result);
}
}
}
And This is the app I want to launch manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.Tab2" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:label="Dig Dit" android:icon="@drawable/ic_launcher">
<activity android:icon="@drawable/ic_launcher" android:label="Dig Dit" android:name="digdit.urlentryclass">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="digdit" />
</intent-filter>
</activity>
</application>
</manifest>
For now Im only intressted by the Android part and it doesn't seem to work. I hope you guys can help me out.