Today i want to explorer android program for make app uninstall from mobile. in android many ways to make app uninstaller, but in this android example i share simple and very easy code that uninstall app which is a installed.
Here i define a package name that i want to uninstall from mobile. if it is installed then it will be uninstall else show you system alert box.
Step 1: Write below code into MainActivity.java
package com.example.appuninstall;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(Intent.ACTION_DELETE);
//Enter app package name that app you wan to uninstall
intent.setData(Uri.parse("package:dev.androidapplink.blog"));
startActivity(intent);
}
}
NOTE: Give permission in AndroidManifest.xml
<original-package android:name="com.android.packageinstaller" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
Step 2: Run Your Project:
Here i define a package name that i want to uninstall from mobile. if it is installed then it will be uninstall else show you system alert box.
Step 1: Write below code into MainActivity.java
package com.example.appuninstall;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(Intent.ACTION_DELETE);
//Enter app package name that app you wan to uninstall
intent.setData(Uri.parse("package:dev.androidapplink.blog"));
startActivity(intent);
}
}
NOTE: Give permission in AndroidManifest.xml
<original-package android:name="com.android.packageinstaller" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
Step 2: Run Your Project:
NOTE: Still Finding Solution For
Permission is only granted to system apps
Thank You
No comments :
Post a Comment