31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
using Android.App;
|
|
using Android.Content;
|
|
using Android.Content.PM;
|
|
using Android.OS;
|
|
|
|
namespace VideoDownloader.Mobile;
|
|
|
|
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
|
|
// M1 공유 타겟(U1): 다른 앱의 공유 시트에 "PC에서 받기" 로 등록
|
|
[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "text/plain", Label = "PC에서 받기")]
|
|
public class MainActivity : MauiAppCompatActivity
|
|
{
|
|
protected override void OnCreate(Bundle? savedInstanceState)
|
|
{
|
|
base.OnCreate(savedInstanceState);
|
|
ReceiveShare(Intent);
|
|
}
|
|
|
|
protected override void OnNewIntent(Intent? intent)
|
|
{
|
|
base.OnNewIntent(intent);
|
|
ReceiveShare(intent);
|
|
}
|
|
|
|
private static void ReceiveShare(Intent? intent)
|
|
{
|
|
if (intent?.Action != Intent.ActionSend) return;
|
|
var text = intent.GetStringExtra(Intent.ExtraText);
|
|
ShareTarget.Deliver(text);
|
|
}
|
|
}
|