Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install applications programmatically without opening Play Store (as Google Drive does)

Tags:

android

Today the Google Drive app asked if I wanted to install the new apps Sheets & Docs.

I've accepted, expecting it to open Google Play Store so I could press install.

It didn't. It just showed me the popup with the permissions of each of the apps to confirm the installation, the same that appears when you press "Install" on any app on the Play Store.

I was not aware this could be done.

How can we reproduce this behavior in an app: have a button "Install App XPTO" which doesn't need to open Google Play Store? Just shows the permissions dialog and proceeds to install it via Play Store?


UPDATE:

For those downvoting because they think this is the same as other questions... It's not!

In this case, the APK is not downloaded by Google Drive app and then installed. Google Drive "tells" Play Store to download & install.

That's the API that I'm interested.

To support my case: after pressing INSIDE Google Drive to install the apps without opening Play Store, the download starts. During the download I've opened the Play Store to check and:

enter image description here

The screenshot proves that it isn't Google Drive downloading the APK and the installing it. It's the Play Store.

like image 475
neteinstein Avatar asked May 16 '14 12:05

neteinstein


People also ask

How can I install an app without Play Store?

From your smartphone or tablet running Android 4.0 or higher, go to Settings, scroll down to Security, and select Unknown sources. Selecting this option will allow you to install apps outside of the Google Play store. Depending on your device, you can also choose to be warned before installing harmful apps.

Can I install an application on Google Drive?

Use and manage appsOn your computer, go to drive.google.com. On the left, click New. Choose an app. After you save your file, you can find it in "My Drive."

How can I open Play Store link in Android programmatically?

If you want to open Google Play store from your app then use this command directy: market://details?gotohome=com.yourAppName , it will open your app's Google Play store pages.


1 Answers

The logs for Google Drive shows that activity responsible for "telling" the Google Play Store to install apps is

com.google.android.apps.docs/com.google.android.apps.docs.app.PhoneskyApplicationInstallerActivity 

which, apparently, "tells"

com.android.vending/com.google.android.finsky.billing.lightpurchase.LightPurchaseFlowActivity 

to install required packages.

So, theoretically, one could create an intent

Intent intent = new Intent("com.android.vending.billing.PURCHASE"); intent.setClassName("com.android.vending",         "com.google.android.finsky.billing.lightpurchase.LightPurchaseFlowActivity"); intent.putExtra(EXTRA_NAME, EXTRA_VALUE); startActivityForResult(intent, 0); 

with correct extra values and voilà!

However, calling LightPurchaseFlowActivity from non-Google signed app is failing, because they are, again apparently (according to the logs), checking the calling package's signature:

W/Finsky(13209): [1] LightPurchaseFlowActivity.setupFromExternalPurchaseIntent: Called from untrusted package. 

So, there, this can not be achieved at this moment.

like image 180
ozbek Avatar answered Oct 07 '22 14:10

ozbek