mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
fix: ensure android can access native app instance before bootstrap
This commit is contained in:
@ -165,11 +165,15 @@ export { androidApp as android };
|
||||
let mainEntry: NavigationEntry;
|
||||
let started = false;
|
||||
|
||||
export function run(entry?: NavigationEntry | string) {
|
||||
function ensureNativeApplication() {
|
||||
if (!androidApp) {
|
||||
androidApp = new AndroidApplication();
|
||||
appCommon.setApplication(androidApp);
|
||||
}
|
||||
}
|
||||
|
||||
export function run(entry?: NavigationEntry | string) {
|
||||
ensureNativeApplication();
|
||||
|
||||
if (started) {
|
||||
throw new Error('Application is already started.');
|
||||
@ -233,6 +237,8 @@ export function getRootView(): View {
|
||||
}
|
||||
|
||||
export function getNativeApplication(): android.app.Application {
|
||||
ensureNativeApplication();
|
||||
|
||||
// Try getting it from module - check whether application.android.init has been explicitly called
|
||||
let nativeApp = androidApp.nativeApp;
|
||||
if (!nativeApp) {
|
||||
|
Reference in New Issue
Block a user