Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to push updates to preinstalled apps without allowing installation from unknown sources
    primarykey
    data
    text
    <p>I have a bunch of Android devices which are to be flashed with custom ROMs and given out to clients. As part of that ROM will be a 'support' app, which is tied to the device. It can't be published to Google Play. I need to be able to offer users the opportunity to download and install updated versions of the software. I have checking, download and install code already implemented however it relies on the devices being configured to enable installation of apps from unknown sources. I need the device to be able to download and install this particular apk, whilst still not allowing any other apps from unknown sources to be installed.</p> <p>Is this possible?</p> <p>(edit: to clarify how the chosen answer finally worked)</p> <p>The code added to the activity was this:</p> <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() +"/update.apk")), "application/vnd.android.package-archive"); intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); intent.putExtra(Intent.EXTRA_ALLOW_REPLACE, true); startActivityForResult(intent, 0); </code></pre> <p>To the android manifest, the following code was added:</p> <pre><code>&lt;uses-permission android:name="android.permission.INSTALL_PACKAGES" /&gt; </code></pre> <p>After installing the app, I used a root file explorer to move the apk from <code>/user/apps</code> to <code>/system/apps</code> then after resetting the phone the app was able to install itself, over the top of itself, without being prompted for the user to enable untrusted sources. The install prompt, listing the permissions the app requires and giving the user the choice to install or not still appears, but that is fine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload