While removing an app can be useful from the point of view of memory clean up in a project the communicates with other modules, it can be used with certain malicious intent.
Regardless, here is how you can remove an app with some chunk of lines of code.
// Replace with the package name of the app you want to uninstall
val packageName = "com.example.package"
val intent = Intent(Intent.ACTION_DELETE)
intent.data = Uri.parse("package:$packageName")
startActivity(intent)
Another method that is also viable, but one has to be proficient with Command Line Interface. Using Android Debug Bridge, which is a command line tool, you can uninstall the application without any permissions or having access of root. Here is how you can uninstall an app using ADB:
adb uninstall com.example.package
Conclusion
Regardless of how you uninstall an application, make sure user consent or action was received.
Leave a Reply