Praween k
Praween k

Reputation: 1035

How can I write a front end program to install and uninstall an app over android device?

By "Program", I mean a desktop front end for installing/uninstalling apps on a phone.Can u please help me out from this? I am not clear what to do ?

Thnx, Praween

Upvotes: 0

Views: 316

Answers (2)

Md Maidul Islam
Md Maidul Islam

Reputation: 2304

First copy your apk file on to your device.suppose you copy your apk fie on download folder on sd card.

 String vsName=Environment.getExternalStorageDirectory().getAbsolutePath()+"/download/";
//your path 
 File file = new File(vsName, "aaa.apk");//put here your apk file      
 System.out.println(":"+file);//checking your path is correct or not   
 Intent install=new Intent(Intent.ACTION_VIEW);
 install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");       
 install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
 startActivity(install);

for uninstall

Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package",
getPackageManager().getPackageArchiveInfo(apkUri.getPath(), 0).packageName,null));
startActivity(intent);

Let me comments if any issue.

Upvotes: 2

Andy Zhang
Andy Zhang

Reputation: 8315

You should edit your original question to clarify (How can I write a program to install and uninstall an app over android device?). Anyhow here's my answer again:

You can write a simple shell script that executes the following commands. I'm assuming you have the Android SDK installed, as it's required.

To install example.apk located somewhere on your desktop hard drive:

cd location_of_sdk\tools
adb.exe install path_to_apk\example.apk

To uninstall the app:

cd location_of_sdk\tools
adb shell

Inside the adb shell execute:

cd /data/app
ls

This will display the apps installed on the device. Look for the .apk associated with the app you want to uninstall. It'll look something like "com.abc.xyz.apk" - then execute:

rm com.abc.xyz.apk
exit

Upvotes: 0

Related Questions