Ich möchte App -Update -Funktionen in meiner Android -Anwendung implementieren, damit ich APK -Datei auf meinen FTP -Server einfügt, das nach dem Herunterladen der APK -App, die versucht hat, für Update -Apps zu starten, in meinem Gerät erfolgreich heruntergeladen wird, dann erhalte ich Popup -Meldung. Das Debug -APK mit einer anderen Version und dem Herunterladen der oberen Version apk.
< /code>
Ich habe Anbieter in Manifestdatei wie unten hinzugefügt < /p>
hinzugefügt
< /code>
Ich habe Berechtigungen in der Manifestdatei hinzugefügt < /p>
< /code>
unten ist mein Code, aus dem ich die App < /p>
aktualisierepublic static void installApk(Context context, File apkFile) {
try {
if (apkFile.exists() && apkFile.canRead()) {
// Log the full path of the APK file to ensure it's correct
Log.d("APK Path", apkFile.getAbsolutePath());
// Generate URI for the APK file using FileProvider
Uri apkUri = FileProvider.getUriForFile(context,
"com.code.app.fileprovider", apkFile);
//Uri apkUri = Uri.parse("content://com.code.app.fileprovider/external_files/Documents/Apk/app_build31.apk");
// Log the generated URI for debugging
Log.d("APK URI", apkUri.toString());
// Intent to install APK
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType(apkUri, "application/vnd.android.package-archive");
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Required flag for non-Activity contexts
installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Grant read URI permission
// For Android 8.0+ (Oreo and above), check if "Install Unknown Apps" permission is required
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (!context.getPackageManager().canRequestPackageInstalls()) {
// If permission is not granted, redirect to the settings screen
Log.e("Enable", "Install Unknown Apps' for this app and retry.");
Intent settingsIntent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
settingsIntent.setData(Uri.parse("package:" + context.getPackageName()));
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Ensure this flag is added
context.getApplicationContext().startActivity(settingsIntent);
return;
}
}
// Start the install APK activity
context.getApplicationContext().startActivity(installIntent);
} else {
Log.e("Install Error", "APK file does not exist.");
}
} catch (Exception e) {
Log.e("Install Error", "Error installing APK: ", e);
}
}
[url=viewtopic.php?t=14917]Ich möchte[/url] App -Update -Funktionen in meiner Android -Anwendung implementieren, damit ich APK -Datei auf meinen FTP -Server einfügt, das nach dem Herunterladen der APK -App, die versucht hat, für Update -Apps zu starten, in meinem Gerät erfolgreich heruntergeladen wird, dann erhalte ich Popup -Meldung. Das Debug -APK mit einer anderen Version und dem Herunterladen der oberen Version apk.[code]
< /code> Ich habe Anbieter in Manifestdatei wie unten hinzugefügt < /p> hinzugefügt
< /code> Ich habe Berechtigungen in der Manifestdatei hinzugefügt < /p>
< /code> unten ist mein Code, aus dem ich die App < /p> aktualisierepublic static void installApk(Context context, File apkFile) { try { if (apkFile.exists() && apkFile.canRead()) { // Log the full path of the APK file to ensure it's correct Log.d("APK Path", apkFile.getAbsolutePath());
// Generate URI for the APK file using FileProvider Uri apkUri = FileProvider.getUriForFile(context, "com.code.app.fileprovider", apkFile); //Uri apkUri = Uri.parse("content://com.code.app.fileprovider/external_files/Documents/Apk/app_build31.apk");
// Log the generated URI for debugging Log.d("APK URI", apkUri.toString());
// Intent to install APK Intent installIntent = new Intent(Intent.ACTION_VIEW); installIntent.setDataAndType(apkUri, "application/vnd.android.package-archive"); installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Required flag for non-Activity contexts installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Grant read URI permission
// For Android 8.0+ (Oreo and above), check if "Install Unknown Apps" permission is required if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (!context.getPackageManager().canRequestPackageInstalls()) { // If permission is not granted, redirect to the settings screen Log.e("Enable", "Install Unknown Apps' for this app and retry."); Intent settingsIntent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES); settingsIntent.setData(Uri.parse("package:" + context.getPackageName())); settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Ensure this flag is added context.getApplicationContext().startActivity(settingsIntent); return; } }
// Start the install APK activity context.getApplicationContext().startActivity(installIntent);
Wenn ich versuche, eine Verbindung zu meinem Redis -Server aus meiner Java -Anwendung mit Jedis herzustellen, erhalte ich JedisconnectionException: Eine Verbindung zu einem für den DNS -Namen...
In dieser Frage geht es nicht um aktuelle Abhängigkeiten, was für diese andere Frage der Fall ist, gegen die jemand diese Frage betrogen hat. Ich werde am Ende ein Modell zum Modell hinzufügen, um...
Bearbeiten: Meine ursprüngliche Frage wurde als geschlossen gewählt, weil sie als Meinungsbasis eingestuft wurde. Das war nicht die Absicht der Frage. Ich dachte, JavaScript gab vielleicht etwas...
Ich habe MySQL-Community-Release-Repo unter meinem Linux-Computer
installiert.
$$ yum info installed | grep 'mysql'
Name : mysql80-community-release
Source :...