什么是空指针异常(java.lang.NullPointerException)以及它们的原因是什么?
可以使用哪些方法/工具来确定原因,以便停止异常导致程序过早终止?
如何更新Play商店应用程序,即如果用户使用旧版本应用程序,我如何从Google Play商店获取应用程序版本信息以提示用户强制/建议更新应用程序.我已经通过了andorid-market-api,这不是官方的方式,也需要谷歌的oauth登录验证.我也经历了android查询 ,它提供了应用内版本检查,但它在我的情况下不起作用.我找到了以下两种选择:
还有其他方法可以轻松完成吗?
version-control android google-apps-marketplace google-play google-play-developer-api
我使用下面的代码通过使用jsoup 从playstore获取versionName我正在获取详细信息,但它抛出了一些异常.
我的代码是
public class ForceUpdateAsync extends AsyncTask<String, String, JSONObject>{
private String latestVersion;
private String currentVersion;
private Context context;
public ForceUpdateAsync(String currentVersion, Context context){
this.currentVersion = currentVersion;
this.context = context;
}
@Override
protected JSONObject doInBackground(String... params) {
try {
latestVersion = Jsoup.connect("https://play.google.com/store/apps/details?id="+context.getPackageName()+"&hl=en")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select("div[itemprop=softwareVersion]")
.first()
.ownText();
} catch (IOException e) {
e.printStackTrace();
}
return new JSONObject();
}
@Override
protected void onPostExecute(JSONObject jsonObject) {
if(latestVersion!=null){
if(!currentVersion.equalsIgnoreCase(latestVersion)){ …Run Code Online (Sandbox Code Playgroud)