I have below code from another forum and I'm using WVersionManager from github.
- Add update with a button click
I have assigned to a button click, ie., if user clicks button it will check for new update.
public class about extends ActionBarActivity {
Button updateButton;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
updateButton = (Button)findViewById(R.id.button_Update);
updateButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
WVersionManager versionManager = new WVersionManager(this);
versionManager.setVersionContentUrl("http://link_to_version_test_file/version.txt");
versionManager.setUpdateUrl("http://link_to_updated_apk_file/latest.apk");
versionManager.checkVersion();
}
});
}
2 . Contents of version.txt file
The version.txt contains these codes :
{"version_code":6,"content":"Version 1.5 <p>Added feature 1</p><li>Added feature 2</li><li>Added feature 3</li><li>Added feature 4</li><li>Added feature 5</li>"}
version_code and content:version is your application's version code and version name respectively as mentioned in manifest file.
to add more features, just add
3 . Giving Internet permission to your app
and in mu application's manifest file.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Well This is all I have done by Far now, Now I want to If I could add code so that when Button pressed would Return Updating an app notification if new updates are available if not Return your app is up to date.
Any Help would be appreciated.