How to install applications programmatically without opening Play Store (as Google Drive does)
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.
Google+ now implements buttons where you can directly download an app (see this link) without clicking the button on the play store site.
The link looks like this:
https://play.google.com/store/apps/details?id=com.example.app&rdid=com.example.app&rdot=1&feature=md
If you add the rdid, rdot and feature parameter it works on my phone (if I type it in the browser, not tested with an intent and not tested to update an app, only installing it).
Edit:
I found out that you only need to add the rdid-parameter to the url. Source: http://www.androidb.com/2014/04/increase-app-installs-with-a-single-trick/
Edit2:
Does not work with an intent. :(