如何在Playstore上获取我的应用程序的当前版本?

时间:2015-08-17 13:39:39

标签: android google-apps-marketplace

我希望在Playstore上有我的应用更新时打开应用程序时显示更新对话框。

我尝试过以下代码但得到回复:

  

Appsresponse:-entriesCount:0

TelephonyManager telephonyManager =
                   (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String udid = telephonyManager.getDeviceId();
MarketSession session = new MarketSession();
session.login("username","password");
session.getContext().setAndroidId("dead000beef");

String query = "pname:<Package name>";
AppsRequest appsRequest = AppsRequest.newBuilder()
            .setQuery(query)
            .setStartIndex(0)
            .setEntriesCount(10)
            .setWithExtendedInfo(true)
            .build();

session.append(appsRequest, new Callback<AppsResponse>() {
            @Override
            public void onResult(ResponseContext context, AppsResponse response) {
               System.out.println("Appsresponse:-"+response);
               // response.getApp(0).getCreator() ...
               // see AppsResponse class definition for more infos
            }
});
session.flush();

我可能使用了错误的Android ID,但我不知道从哪里获得Android ID。

1 个答案:

答案 0 :(得分:0)

imho as njzk2说是烦人的,但如果你想继续这种方式你可以尝试这个(检查谷歌链接示例和github如何完成):

https://code.google.com/p/android-query/wiki/Service

https://github.com/androidquery/androidquery

有一个很好的编码