I update the new version of my application in play store. Want to make auto update in those phone where the application is already installed. I did this work.
dependencies {
compile 'org.jsoup:jsoup:1.10.2'
}
and in MainActivity
I did this work-
public class MainActivity extends AppCompatActivity {
String newVersion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new FetchAppVersionFromGooglePlayStore().execute();
}
class FetchAppVersionFromGooglePlayStore extends AsyncTask<String, Void, String> {
protected String doInBackground(String... urls) {
try {
return
Jsoup.connect("https://play.google.com/store/apps/details?id=" + "com.directed.android.smartstart" + "&hl=en")
.timeout(10000)
.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 (Exception e) {
return "";
}
}
protected void onPostExecute(String string) {
newVersion = string;
Log.d("new Version", newVersion);
}
}
}
But, still not working. How can I solve this problem?