2014-05-21 64 views
0

我试图在我的应用程序内显示更新提醒,如果我已在我的google play app中更新,请参阅this作为参考,我已设法从Play商店获得响应。但从Play商店看来更新的反应就像这样。应用程序更新来自Google play的应用程序内部提醒

We're sorry, the requested URL was not found on this server

我的问题是我怎么知道我的应用程序里面,如果有可用更新的谷歌玩店?

和谷歌播放不支持apk中的私人更新链接,所以有没有其他的方式来获取应用程序内的更新从playstore。 在此先感谢。

回答

1

根据您将如何经常做的更新,你可以简单地在您的服务器上的网页,让您的可用最新版本,如果它不符合目前的一个,提示用户意图在您的应用中打开Play商店。

基本上,ask the server最新的版本是什么(你需要在一个try/catch来包装它并添加网络许可清单):

URL url = new URL("mysite.com/thefile.txt"); 
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); 
String str; 
while ((str = in.readLine()) != null) { 
    // str is one line of text; readLine() strips the newline character(s) 
} 
in.close(); 

来自服务器的响应可能会是像{"latestVersion": "1.004"},你可以查看当前安装的版本:

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); 
version = pInfo.versionName; 

比较他们,并提示一个对话框或任何用户,然后推出Play商店中,通过使用代码中发现here

final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object 
try { 
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); 
} catch (android.content.ActivityNotFoundException anfe) { 
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); 
} 

为了澄清,你会在你的服务器手动更新版本,这样可能会或可能不会是你根据你的更新的频率,以及如何往往你忘事的一个选项:P

+0

你能告诉我如何从服务器得到你所说的回复吗?我正在做的所有其他部分,但我没有取得回应。 – Sree

+0

完成,祝你好运 –

+0

我很抱歉问,我可以知道谷歌Play商店里这个'thefile.txt'是什么吗? – Sree

相关问题