mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-19 22:37:09 -04:00
[app] Ask user to enable unknown sources for F-Droid when needed
This still needs to be tested on old Android versions < 31
This commit is contained in:
@@ -24,6 +24,8 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import org.fdroid.fdroid.data.Apk;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
@@ -48,6 +50,15 @@ public class DefaultInstaller extends Installer {
|
||||
|
||||
@Override
|
||||
protected void installPackageInternal(Uri localApkUri, Uri canonicalUri) {
|
||||
// ask to enable unknown sources on old Android versions
|
||||
if (Build.VERSION.SDK_INT >= 26 && Build.VERSION.SDK_INT < 31) {
|
||||
if (!context.getPackageManager().canRequestPackageInstalls()) {
|
||||
Intent i = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
context.startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
Intent installIntent = new Intent(context, DefaultInstallerActivity.class);
|
||||
installIntent.setAction(DefaultInstallerActivity.ACTION_INSTALL_PACKAGE);
|
||||
|
||||
Reference in New Issue
Block a user