Я пишу приложение maui Android , которое получает файлы, разделяемые из WhatsApp или Telegram .
Определено только одно действие и создается как Singlets Onnewintent . Это само по себе не является проблемой, но когда я делюсь файлом из, скажем, Telegram , создается совершенно новый экземпляр приложения, так что у меня есть два экземпляра приложения, работающего одновременно. Это приводит к сбоям. Что происходит?
manifest
...
code
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true,
LaunchMode = LaunchMode.SingleTask,
NoHistory = true,
Exported = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation |
ConfigChanges.UiMode | ConfigChanges.ScreenLayout |
ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
//whatsapp & telegram send binaries as octet-stream
[IntentFilter(new[] { Android.Content.Intent.ActionSend },
Categories = new[] { Android.Content.Intent.CategoryDefault },
DataMimeType = @"application/octet-stream",
Icon = "@mipmap/appicon")]
public partial class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
if (Intent.Action == Intent.ActionSend || Intent.Action == Intent.ActionView)
HandleSendOrViewIntent();
}
//This method is NEVER called
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
if (Intent.Action == Intent.ActionSend || Intent.Action == Intent.ActionView)
HandleSendOrViewIntent(true);
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... documented