I need to trigger an uninstall of a certain app from within my own app. The only thing i have is the apps apk, even tho it doesn't have to be the same version as the installed app.
The uninstall would be handled by android of course. Just like installing an app from a given apk file.
Is there a way how i can put together an intent to make android open the responsible system service and and ask the user to uninstall or something like that?
The app to be uninstalled can change, so i can't use a constant packagename or something like that.
Is there some way to do this? I know you can extract the packagename from an apk, but it seems like a lot of work and probably overkill.
Using Intent.ACTION_DELETE intent
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.example.mypackage"));
startActivity(intent);
You can get your own package name from context;
getApplicationContext().getPackageName();
Related
I'm developing an Android app.
I used the following code to uninstall a specific application.
Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:com.example.tharindurasanga.locationtracker"));
startActivity(intent);
This code really works fine but not giving what I'm expecting since this is resulting a prompt saying user to confirm the app uninstallation. I need to uninstall the app silently without user confirmation.
Can someone suggest me another method of doing this or help me to remove this prompt?
How can i write a function that can remotely self-destruct it, ie delete that application from the phone?
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.example.myapplication"));
startActivity(intent);
This code does not work on Android 10+
You can purge application files by enumerating app directory and deleting everything in there plus removing your application files on SD card. Uninstalling application itself is a different beast altogether. Non system apps cannot do that AFAIK (starting from android 2.0?).
I have struck an idea of creating an app that automatically installs all the .apk packages placed inside a particular folder. In context to this, I want to learn how do I programmatically access installer service ?
Please enlighten me in this regard.
Your best bet would be to set an intent with type application/vnd.android.package-archive and then start installer activity:
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///path/to/your.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);
Check out Install Application programmatically on Android
Also, note, that for security reasons, you cannot install an apk 'silently' or automatically without user agreement. Therefore, the best you can do is like above.
I have searched ALOT now, i cant find a solid way to run apps like calendar, camera, facebook, twitter, insatgram, and all kinds of apps in android. I know that i need to use intents, but HOW can i do it? I really need help! Please help me and thanks alot!
There is no such concept in Android as "run apps". You start activities. Talented developers do not focus on specific apps (e.g., "facebook, twitter, insatgram"), because those apps may not exist on any given device. Instead, you focus on generic capabilities (e.g., use an ACTION_SEND Intent with startActivity() to share something, create a launcher by using PackageManager to find those activities that support ACTION_MAIN and CATEGORY_HOME).
If you want to launch some other application from your android application then you should know the package name for that particular application For example for launching facebook use
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);
Otherwise this can also be used
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
If you want to launch the default android applications installed for some particular kind of operation then you can use implicit intents for that. For example to start a browser you can use
Uri webpage = Uri.parse("http://www.android.com");
Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);
startActivity(intent);
You should take also take a look at intents and intent filters and how to allow other apps to open your application.
I've written an Android App which is primarily targeted to Android Tablets without the Market installed, which means the user cannot easily update the App. My idea is to download the apk file and do whatever the MArket is doing with the apk file.
As the app is preinstalled on the Tablets there is no restriction in Permissions, but the device must not to be rooted.
Seems the following code allows the user to install the apk after detecting a new version and downloading the apk file:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
well i think that you just can do something like these. Verify version if version is lower app don't run.