mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
startActivityForResult(): add initial support for android.intent.action.INSTALL_PACKAGE
For now this just calls 'android-translation-layer --install' on the given APK file. Which would then show the dynamic launcher portal.
This commit is contained in:
parent
494b4e7134
commit
7b0341123b
1 changed files with 14 additions and 0 deletions
|
@ -27,6 +27,7 @@ import android.view.Window;
|
|||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -337,6 +338,19 @@ public class Activity extends ContextThemeWrapper implements Window.Callback, La
|
|||
}
|
||||
} else if (FILE_CHOOSER_ACTIONS.contains(intent.getAction())) {
|
||||
nativeFileChooser(FILE_CHOOSER_ACTIONS.indexOf(intent.getAction()), intent.getType(), intent.getStringExtra("android.intent.extra.TITLE"), requestCode);
|
||||
} else if ("android.intent.action.INSTALL_PACKAGE".equals(intent.getAction())) {
|
||||
try {
|
||||
Process p = new ProcessBuilder("/usr/bin/env", "android-translation-layer", "--install", intent.getData().getPath()).start();
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue == 0) {
|
||||
onActivityResult(requestCode, -1 /*RESULT_OK*/, new Intent());
|
||||
} else {
|
||||
onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent());
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent());
|
||||
}
|
||||
} else {
|
||||
Slog.i(TAG, "startActivityForResult: intent was not handled. Calling onActivityResult(RESULT_CANCELED).");
|
||||
onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue