简体   繁体   English

Android:获取有关应用购买的信息

[英]Android: Get information about app purchase

Is there any android api to get information about the purchase of the app? 是否有任何Android API可以获取有关应用程序购买的信息? I don't talk about in-app purchases. 我没有谈论应用内购买。 Just the Plain APP-Purchase. 只是普通的APP购买。

I need any unique identifier like an transaction id or something like that. 我需要任何唯一的标识符,例如交易ID或类似的东西。

As per my understanding of question you want to get information of your app buyers or you want to check particular user's purchase status for your app. 根据我对问题的理解,您想获取有关应用购买者的信息,或者您要检查特定用户对应用的购买状态。

AFAIK : As of now I can't able to see any buyers info for your android application purchase. AFAIK:到目前为止,我无法看到您购买的android应用程序的任何买家信息。 Reference : https://support.google.com/googleplay/android-developer/answer/6056620?hl=en 参考: https : //support.google.com/googleplay/android-developer/answer/6056620?hl=zh_CN

But in past may be we were able to see such information. 但是过去也许我们能够看到这些信息。 Reference : Android Market (Google Play). 参考: Android电子市场(Google Play)。 Get buyer information 获取买家信息

As far as I know there is no way to persist this information across app uninstall/reinstalls. 据我所知,没有办法在整个应用程序卸载/重新安装过程中保留此信息。 You can get the installation timestamp but this will be reset when reinstalling. 您可以获得安装时间戳记,但是在重新安装时将重置此时间戳记。

However, a workable solution may be to set a flag in SharedPreferences and save the data using Android Backup ( http://developer.android.com/guide/topics/data/backup.html#SharedPreferences ) 但是,可行的解决方案可能是在SharedPreferences中设置一个标志并使用Android备份( http://developer.android.com/guide/topics/data/backup.html#SharedPreferences )保存数据

As mentioned in other answers, it looks like there's no public API for it. 如其他答案中所述,似乎没有公共API。 (I believe, the reason for it is that by default - once user starts the app - he has already got if from Google Play. So in the ideal world, there should be no need for this check) (我相信,原因是默认情况下-用户启动该应用后-他已经从Google Play获得了该信息。因此,在理想情况下,无需进行此检查)

If I were you, I'd implement some tiny API endpoint on your server side and sends it hashed version of the user's accountId (see Accessing Google Account Id /username via Android ) and Timestamp-response(or any other reasonable data back) of initial call of this method for this particular user Id (ie once he changed his phone - you'll still track him). 如果您是我,我会在服务器端实现一些微型API终结点,并将其发送给用户的accountId(请参阅通过Android访问Google帐户ID /用户名 )的哈希版本和Timestamp-response(或返回的任何其他合理数据)此方法针对此特定用户ID的初始调用(即,一旦他更改了电话,您仍将对其进行跟踪)。

To get current Account do this: 要获得当前帐户,请执行以下操作:

    Account[] accounts = AccountManager.get(this).getAccountsByType("com.google"); 
    if (accounts.length != 0) {
         String myEmailid=accounts[0].toString();
    }

(taken from here ) (从这里拍摄)

Tested on API 19 and API 23 (In Android M it requires a bit extra work due to permission-check) API 19API 23上进行了测试(在Android M中,由于需要进行权限检查,因此需要做一些额外的工作)

最可靠的方法是创建您自己的(网络)服务,并使用Google用户名注册该应用程序( 如何在Android手机上检索已登录的Google帐户? ),然后在以后重新安装时检查其注册情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM