how can i make my application auto updatable ? pls help.
process that should not want user confirmation.it should be run after login automatically
`
new Thread()
{
#SuppressWarnings({ "null", "deprecation" })
#Override
public void run() {
Looper.prepare();
Handler refresh1 = new Handler(Looper.getMainLooper());
refresh1.post(new Runnable() {
public void run()
{
//i want do here background process that search applications new version and install it automatically.
}
}
}
}//ends thread
This is not possible, except perhaps on rooted devices. Apps cannot install other apps, including updates to their own app, without user involvement.
You can't do that... all you can do is use the Android Market API (not official) to alert the users with a new update: https://code.google.com/p/android-market-api/
Also, if you're using some webservice, you can make a validator with it... but not a single chance to auto update an app without user confirmation.
You could force users to upgrade by other means. Have your app check a URL on startup, perhaps an XML file on your website. The XML file contains the android:versionCode of the latest app release. The app then compares the retrieved version code value with its own version code, and if an upgrade is required, you can then have the app display a message "Upgrade required" or something similar, and you can either have it be a reminder message that pops up on startup (using a Toast, maybe) every time the app is run, or you can have the app refuse to function until it is upgraded.
Please note, implementing this type of behavior in your apps may violate app store policies, especially for paid apps.
Related
We have made an android app using Xamarin and make use of microsoft appcenter build and distribute, we migrated this app from using HockeyApp.
Appcenter allows us to make a QR code which people can then scan and they can install the application this way, this works fine. Another way users can install the application is by using the app center app, this also works.
However when we push out an update we start to get issues. We have allowed using in app updates so when we push a new version a pop up will show in the app requiring that you update it. There is a download button available. Clicking this will start the download. After the download is finished a screen is showed with the text 'Staging app' and the following error message : "There was a problem while parsing the package." This happens both using the app center app or the QR code to install the app. We can also install a new version using the microsoft app center app, in this case it does work but we would like the in app updates to work properly too.
How can we get this to work so that users can also do in app updates where the new version can actually be installed? The code to activate distribute is as follows :
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Forms.Init(this, bundle);
ContextMenuViewRenderer.Preserve();
appVersion = "" + this.PackageManager.GetPackageInfo(ApplicationContext.PackageName, 0).VersionName;
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
}
AppCenter.Start(_appCenterId,
typeof(Analytics), typeof(Crashes), typeof(Distribute));
CheckForUpdates();
}
private void CheckForUpdates()
{
Distribute.SetEnabledAsync(true);
}
private void UnregisterManagers()
{
Distribute.SetEnabledAsync(false);
}
Thanks for the help.
Problem while parsing package
About this problem,
You need to check whether the apk file has been downloaded fully first. Check the size of downloaded apk file is the same with the server.
Second, you need to check whether the name of apk file is legal, such as can not contain space char.
Third, check the android:minSdkVersion of AndroidManifest is higher than your current environment.
I would like to ensure that users of my app are always using the latest version. If they haven't updated the app to the latest version, I would like to prevent them from using the app.
What is the best way to do this ? In each activity I can check my apps website to see what the latest version should be, and compare it with the device,but it seems clunky.
Isn't there a better way to display some kind of UI that prevents the user from using any of the other activities ?
in Splash Activity check last number version release from server, if number version Server bigger of BuildConfig.VERSION_CODE, user need update app, you can show dialog and dialog.setCancelable(false).
Have a local string that you change every update and have a string on a server that you also change when you update. Then every app open compare local to server. E.G.
Someone hasn't updated the app
Local string is 1.11
Server string is 1.14
Compare them and since they aren't the same, do something to block usage.
As stated by Rasoul Miri compare the BuildConfig.VERSION_CODE with your version value saved on server and if it doesnt match then open an activity which shows information about update of your app and override the onBackPressed() method of that activity and enter this
#Override
public void onBackPressed() {
System.exit(0); // Kill the app
super.onBackPressed();
}
Probably the best solution for this is to check BuildConfig.VERSION_CODE and compare it with the version code in the server. Add an alert dialog and redirect it Playstore update screen on the Alert positive response button, and override the onBackPressed() method if the user tries to do anything else. This will force them to update to latest version of the application.
#Override
public void onBackPressed() {
System.exit(0); // Kill the app
super.onBackPressed();
}
I am using Android HockeyAppSDK to deploy updates to an application. I am trying to use the docs to customise the default UpdateManager class to allow updates to be installed automatically, without prompting the user to accept the update.
I am quite unsure of how to handle this. The obvious way (in my mind anyway) is to do the following:
private void checkForUpdates () {
UpdateManager.register (this, Constants.HOCKEY_API_KEY, new UpdateManagerListener() {
public void onUpdateAvailable() {
//I assume stuff will need to be handled here
}
});
}
Has anyone done this before, or can find a way to do it?
Many thanks
After emailing the support team for Hockey, they believe that within their current compiled API it is not possible to perform an update without prompting users to accept.
The whole source would require modification and compilation before working as expected it seems.
You can use UpdateTask from library
How do i check if a in app purchase has been done before?
So that my user doesnt need to repurchase the in app purchase upon uninstalling and reinstalling the app?
I have set my in app item to managable in the android market publish page.
i have read about RESTORE_TRANSACTION but I do not know what i need to look for inside this response and also how to test this.
Any help would be greatly appreaciated.
You need to restore the transactions, using the RESTORE_TRANSACTION flag you specified above. You should only do this once, when the application starts for the first time or if the user clears the data.
I would advice to make this process simpler for yourself, you looking into the AndroidBillingLibrary, which allows you to interface with the Android In App Billing in a much simpler manner.
Here is a snippet of how the transactions are restored:
private void restoreTransactions() {
if (!mBillingObserver.isTransactionsRestored()) {
BillingController.restoreTransactions(this);
Toast.makeText(this, R.string.restoring_transactions, Toast.LENGTH_LONG).show();
}
}
I'm developing a non-public Android app, i.e. the app won't be available in the global Android Market. The app will be installed on a limited number of clients, e.g. by using an apk file.
How can I enable an auto-update functionality in this app?
I see different potential options (I do not know if those are technically hard or even impossible to implement or if there are any existing functionalities that can be reused):
On each launch the app tests if a new version exists (by requesting a server), if so downloads the new apk and replaces itself with the new version.
Use (or develop?) a separated app or service that undertakes the update-check and replacement-process.
Use (or develop?) a private market app which has an auto-update option. This option is similar to the second one, but more generic: The market app would be connected to a repository, i.e. it would handle an arbitrary number of (private) apps.
I would prefer option one since the auto-update functionality is included in the app which needs less development efforts.
janjonas, in the company I work we had a similar problem with Windows Mobile 6.x, and we use pretty much the same solution pointed by EboMike:
The main app check if it's updated, against a WebService. It receives the current version & the URL from where download the new version, if necessary. The main app then start the Updater app, passing the URL, and quit.
The Updater do the download of the new program, via HTTP, showing to the user the % downloaded. The user can cancel the download anytime, in a controlled way, and the Updater can registry this cancellation.
Since the new app is downloaded, the Updater run the new app, and quit.
I think option one is the least amount of work for you, and actually the cleanest one too since it will go through the proper channel of using Android's built-in package installer which includes user notification and the option for the user to abort the installation if desired.
You already have it all outlined - check for a new version on a server (would be nice to give the user the option to turn that off), and if there is a new version, you could either just link to the URL with the APK (which will, IIRC, use the browser's download manager to download it), or you could download it with your app and then point the intent to your local file. Using the HTTP link is technically less work and cleaner - the more you let the operating system do, the better - unless there's a reason not to.
Enabling "Install non-market app" is still needed for any application outside the Google Play. If it not enabled, the installation process is going to ask for it and redirect the user to the Application Settings, and after that, the user can install the app.
Depending on your needs, you can delegate to a third part lib.
Some of the permissions we'll use to get this done are the following:
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Let me explain a bit... The last, WRITE_EXTERNAL_STORAGE, is self-explanatory. With ACCESS_SUPERUSER we'll tell the system that we intend to use root privileges. READ_EXTERNAL_STORAGE will be needed in the future in order for your app to read files on SD card.
Assuming that you have downloaded the file and that all those devices can be rooted (limited number of clients, not on Play, etc.), you could do this:
String filePath = Environment.getExternalStorageDirectory().toString() + "/your_app_directory/your_app_filename.apk";
Process installProcess = null;
int installResult = -1337;
try {
installProcess = Runtime.getRuntime().exec("su -c pm install -r " + filePath);
} catch (IOException e) {
// Handle IOException the way you like.
}
if (installProcess != null) {
try {
installResult = installProcess.waitFor();
} catch(InterruptedException e) {
// Handle InterruptedException the way you like.
}
if (installResult == 0) {
// Success!
} else {
// Failure. :-/
}
} else {
// Failure 2. :-(
}
Here might be a very lame method but for some companies, if you believe its applicable, this might be very easy to implement.
Create an password screen (passwordActivity) that asks a password to access the application.
Once the password is entered, raise a flag (set a boolean value from false to true using sharedpreferences)
Place the .apk file on Google Store.
Change the password once everyone installs the app, and release a new update on Google Play Store.
Since the software is going to cache the flag value, the password screen won`t show up even the password is change. It will only show up for new installations so might need to repeat the process.
Note: This method might better fit if there is not hundreds of users using the application. And don`t forget this method is also not secure. To sum up, if you are looking a way to keep the application private and have no security concerns, this is what I recommend.
Update app
Make sure that you already have your new apk download on location
void installNewVersion(String location) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(location + "app-debug.apk")),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}