How can i install apk from android market through code?
I want to install the apk from android market into my android device through code.
Is there 开发者_运维技巧any solution to do this operation.
I have heard that you if you copy the apk into the sdcards folder:
/data/app
Then the app is installed but you would probably need to be root, simple enough to create an app to do it but I am not sure if it will work.
Other than that, I do not believe you can, otherwise apps like AppBrain would do it.
Hope that helps.
I'm not sure what you mean by "install through code". If you have an .apk stored on your Windows/Mac/Linux machine and you need to install it onto your Android device, I would use Android Debug Bridge.
It doesn't require active inputs from your Android device but you have to make sure that
- You have the appropriate USB driver for your Android device installed on your computer
- You have USB Debugging enabled on your Android device
- You have an active USB connection established between your computer and your Android device.
- You have Android Debug Bridge installed on your computer. The most common way to accomplish this is to download the Android SDK; be sure to check ‘Android SDK Platform-tools’ when you are prompted to select packages.
That was the hard part. ADB is the easiest command-line program you'll use on your computer.
To install an .apk you simply invoke...
adb install C:\AppsFolder\Name_of_App.apk
...replacing *C:\AppsFolder\Name_of_App.apk* with the directory and filename of your actual .apk -- the destination directory is selected automatically on your android device.
If you want to select the destination directory...
adb push C:\AppsFolder\Name_of_App.apk /system/app/
or
adb push C:\AppsFolder\Name_of_App.apk /data/app/
...note the space between .apk and /system (or /data).
This isn't a step-by-step how-to...you'll want to Google an ADB manpage and get more than just the highlights.
For example i am installing Photoshop Express through code in android.
Intent intent = new Intent(Intent.ACTION_VIEW
,Uri.parse("market://details?id=com.adobe.psmobile"));
startActivity(intent);
For any other app you just need to change the package name that is mentioned after id. It works for me perfectly. Try it.
I've just dealt with that issue, You need to check the details of your application on the market, determine whether an upgrade is mandatory, and then prompt the user to upgrade, and refer them to the Play-Store to the app, this is my full solution.
精彩评论