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

Android 如何在Playstore上获取我的应用程序的当前版本?,android,google-apps-marketplace,Android,Google Apps Marketplace,当Playstore上有我的应用更新时,我想在应用打开时显示更新对话框 我尝试了以下代码,但得到了响应: Appsresponse:-entriesCount:0 TelephonyManager电话管理器= (TelephonyManager)getSystemService(Context.TELEPHONY_服务); 字符串udid=telephonyManager.getDeviceId(); MarketSession会话=新的MarketSession(); 登录(“用户名”、“密码

当Playstore上有我的应用更新时,我想在应用打开时显示更新对话框

我尝试了以下代码,但得到了响应:

Appsresponse:-entriesCount:0

TelephonyManager电话管理器=
(TelephonyManager)getSystemService(Context.TELEPHONY_服务);
字符串udid=telephonyManager.getDeviceId();
MarketSession会话=新的MarketSession();
登录(“用户名”、“密码”);
session.getContext().setAndroidId(“dead000beef”);
String query=“pname:”;
AppsRequest AppsRequest=AppsRequest.newBuilder()
.setQuery(查询)
.setStartIndex(0)
.setEntriesCount(10)
.setWithExtendedInfo(真)
.build();
append(appsRequest,new Callback()){
@凌驾
public void onResult(ResponseContext,AppsResponse-response){
System.out.println(“应用响应:-“+响应”);
//response.getApp(0.getCreator()。。。
//有关更多信息,请参阅AppsResponse类定义
}
});
session.flush();

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

正如njzk2所说,imho很烦人,但如果你想继续这样做,你可以尝试一下(查看google链接示例和github如何实现):


正如njzk2所说的,有一个很好的编码

imho很烦人,但是如果你想继续这样做,你可以尝试一下(查看google链接示例和github它是如何实现的):


有一个好的编码

为什么这是必要的?用户会相对较快地知道何时有更新,因为Play store会通知用户自己。我希望用户在每次打开应用程序时都会收到通知,如果应用程序没有更新,这对用户来说非常烦人。请重新考虑。为什么这是必要的?用户会相对较快地知道何时有更新,因为Play store会通知用户自己。我希望用户在每次打开应用程序时都会收到通知,如果应用程序没有更新,这对用户来说非常烦人。请重新考虑。
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();