728x90
728x170

ANDROID 에서 다른 APP을 제거하는 방법입니다. 
(자마린 단체창에 물어본 분이 있어 호기심에 알아봤는데 벌써 누가 답변을 하셨네요 ㅎ)
 
MainActivity.cs

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Widget;

namespace Maui.DeleteApp;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        try
        {
            var name = "com.test.app"; //this.ApplicationContext.PackageName;
            Intent intent = new Intent(Intent.ActionDelete);
            intent.SetData(Android.Net.Uri.Parse("package:" + name));
            StartActivity(intent);
        }
        catch (Exception ex)
        {
            Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            Finish();
        }
    }
}

 
권한 주기
AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
	<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
		
	</application>
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.INTERNET" />
    
	<uses-permission android:name="android.permission.DELETE_PACKAGES" />
	<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
</manifest>


결과 (test app 제거)

[SOURCE]
https://github.com/kei-soft/Maui.DeleteApp

GitHub - kei-soft/Maui.DeleteApp

Contribute to kei-soft/Maui.DeleteApp development by creating an account on GitHub.

github.com

 

728x90
그리드형
Posted by kjun
,