Following links are the improved version by others:
- Save time to implement check new update available since Google play havent provide any API to check (written at Jan 2013)
- Ask user for rate
- Show Alert Dialog with new update content and 3 options button: update now, remind me later and ignore this version.
- Callback to implement your own custom logic
- Show Alert Dialog to prompt user ask for rating
- Few lines of code to implement.
- v1.1 Ask for rating
- v1.2 Add OnReceive callback when response
- v1.3 Fix error handling callback
-
Copy latest version of jarfile in folder JAR to your project libs folder. You may also check out src used as project library.
-
For check version, in your Activity,
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); WVersionManager versionManager = new WVersionManager(this); versionManager.setVersionContentUrl("http://bit.ly/11c7Pnb"); // your update content url, see the response format below versionManager.checkVersion(); }
-
The Version Content Url must return response with json format which follow this format. To save time for testing you may just put content in static text file.
{ "version_code": 2, "content": "Version 2.0 <p>New features:</p><li>Added feature A</li><li>Added feature B</li><li>Added feature C</li><li>Added feature D</li><li>Added feature E</li><li>Added feature F</li><li>Added feature G</li>" }
-
You can also customize label and reminder time eg:
versionManager.setUpdateNowLabel("Custom update now label"); versionManager.setRemindMeLaterLabel("Custom remind me later label"); versionManager.setIgnoreThisVersionLabel("Custom ignore this version"); versionManager.setUpdateUrl("http://your_app_url"); // this is the link will execute when update now clicked. default will go to google play based on your package name. versionManager.setReminderTimer(10); // this mean checkVersion() will not take effect within 10 minutes
-
Set callback for your own implementation:
versionManager.setOnReceiveListener(new OnReceiveListener() { @Override public boolean onReceive(int status, String result) { // implement your own compare logic here return false; // return true if you want to use library's default logic & dialog } });
-
Copy latest version of jarfile in folder JAR to your project libs folder. You may also check out src used as project library.
-
Add following lines to prompt user dialog for rating
WVersionManager versionManager = new WVersionManager(this); versionManager.askForRate();
-
Customize label for ask for rate:
versionManager.setTitle("Please rate us"); // optional versionManager.setMessage("We need your help to rate this app!"); // optional versionManager.setAskForRatePositiveLabel("OK"); // optional versionManager.setAskForRateNegativeLabel("Not now"); // optional
Copyright 2013 Winson Tan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.