How to transfer a parameter from an android application to a unity game on android?

I use Xamarin Form to create an android application.
My code is:

Intent intent = Android.App.Application.Context.PackageManager.GetLaunchIntentForPackage("com.myapp.game_unity");
if (intent != null)
{
    intent.AddFlags(ActivityFlags.NewTask);
    intent.PutExtra("test_key", "test_val");
    Android.App.Application.Context.StartActivity(intent);
}
else
{
    intent = new Intent(Intent.ActionView);
    intent.AddFlags(ActivityFlags.NewTask);
    intent.SetData(Android.Net.Uri.Parse("market://details?id=com.myapp.game_unity"));
    intent.PutExtra("test_key", "test_val");
    Android.App.Application.Context.StartActivity(intent);
}

where I want to pass the parameter “test_val” to the game. The game starts, but I can’t get the parameter.

In the game, I try to get this parameter, but nothing works.
My code:

var intent = new AndroidJavaClass("android.content.Intent");
var extras = intent.Call<AndroidJavaObject>("getExtras");
var val = extras.Call<string> ("getString", "test_key");

How can I pass the parameter with android app to the unity game (android)?

Unity version: 2019.3.0f6

Answer: Call Unity apk with Intent and read extras - Questions & Answers - Unity Discussions

string arguments = "";

AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

AndroidJavaObject intent = currentActivity.Call<AndroidJavaObject>("getIntent");
bool hasExtra = intent.Call<bool> ("hasExtra", "test_key");

if (hasExtra) {
    AndroidJavaObject extras = intent.Call<AndroidJavaObject> ("getExtras");
    arguments = extras.Call<string> ("getString", "test_key");
}