mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +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 mainEntry: NavigationEntry;
|
||||||
let started = false;
|
let started = false;
|
||||||
|
|
||||||
export function run(entry?: NavigationEntry | string) {
|
function ensureNativeApplication() {
|
||||||
if (!androidApp) {
|
if (!androidApp) {
|
||||||
androidApp = new AndroidApplication();
|
androidApp = new AndroidApplication();
|
||||||
appCommon.setApplication(androidApp);
|
appCommon.setApplication(androidApp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function run(entry?: NavigationEntry | string) {
|
||||||
|
ensureNativeApplication();
|
||||||
|
|
||||||
if (started) {
|
if (started) {
|
||||||
throw new Error('Application is already started.');
|
throw new Error('Application is already started.');
|
||||||
@ -233,6 +237,8 @@ export function getRootView(): View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getNativeApplication(): android.app.Application {
|
export function getNativeApplication(): android.app.Application {
|
||||||
|
ensureNativeApplication();
|
||||||
|
|
||||||
// Try getting it from module - check whether application.android.init has been explicitly called
|
// Try getting it from module - check whether application.android.init has been explicitly called
|
||||||
let nativeApp = androidApp.nativeApp;
|
let nativeApp = androidApp.nativeApp;
|
||||||
if (!nativeApp) {
|
if (!nativeApp) {
|
||||||
|
Reference in New Issue
Block a user