@@ -40,7 +40,7 @@ function isString(value): value is string {
40
40
}
41
41
42
42
function createAlertDialog ( options ?: DialogOptions & MDCAlertControlerOptions ) : androidx . appcompat . app . AlertDialog . Builder {
43
- const activity = androidApp . foregroundActivity as globalAndroid . app . Activity ;
43
+ const activity = androidApp . foregroundActivity || androidApp . startActivity as globalAndroid . app . Activity ;
44
44
const alert = new androidx . appcompat . app . AlertDialog . Builder ( activity ) ;
45
45
alert . setTitle ( options && isString ( options . title ) ? options . title : null ) ;
46
46
alert . setMessage ( options && isString ( options . message ) ? options . message : null ) ;
@@ -83,7 +83,7 @@ function createAlertDialog(options?: DialogOptions & MDCAlertControlerOptions):
83
83
84
84
function showDialog ( builder : androidx . appcompat . app . AlertDialog . Builder , options : DialogOptions & MDCAlertControlerOptions , resolve ?: Function ) {
85
85
const dlg = builder . show ( ) ;
86
- const activity = androidApp . foregroundActivity as globalAndroid . app . Activity ;
86
+ const activity = androidApp . foregroundActivity || androidApp . startActivity as globalAndroid . app . Activity ;
87
87
if ( ( activity as any ) . _currentModalCustomView ) {
88
88
const view = ( activity as any ) . _currentModalCustomView as View ;
89
89
const context = options . context || { } ;
@@ -220,7 +220,7 @@ function addButtonsToAlertDialog(alert: androidx.appcompat.app.AlertDialog.Build
220
220
} )
221
221
) ;
222
222
}
223
- const activity = androidApp . foregroundActivity as globalAndroid . app . Activity ;
223
+ const activity = androidApp . foregroundActivity || androidApp . startActivity as globalAndroid . app . Activity ;
224
224
alert . setOnDismissListener (
225
225
new android . content . DialogInterface . OnDismissListener ( {
226
226
onDismiss : function ( ) {
@@ -265,7 +265,7 @@ export class AlertDialog {
265
265
if ( ! this . dialog ) {
266
266
const alert = createAlertDialog ( this . options ) ;
267
267
268
- const activity = androidApp . foregroundActivity as globalAndroid . app . Activity ;
268
+ const activity = androidApp . foregroundActivity || androidApp . startActivity as globalAndroid . app . Activity ;
269
269
alert . setOnDismissListener (
270
270
new android . content . DialogInterface . OnDismissListener ( {
271
271
onDismiss : function ( ) {
@@ -438,7 +438,6 @@ export function login(arg: any): Promise<LoginResult> {
438
438
439
439
return new Promise < LoginResult > ( ( resolve , reject ) => {
440
440
try {
441
- const context = androidApp . foregroundActivity ;
442
441
const stackLayout = new StackLayout ( ) ;
443
442
stackLayout . padding = 4 ;
444
443
const userNameTextField = new TextField ( ) ;
@@ -513,7 +512,7 @@ export function action(arg: any): Promise<string> {
513
512
514
513
return new Promise < string > ( ( resolve , reject ) => {
515
514
try {
516
- const activity = androidApp . foregroundActivity || androidApp . startActivity ;
515
+ const activity = androidApp . foregroundActivity || androidApp . startActivity as globalAndroid . app . Activity ;
517
516
const alert = new androidx . appcompat . app . AlertDialog . Builder ( activity ) ;
518
517
const message = options && isString ( options . message ) ? options . message : '' ;
519
518
const title = options && isString ( options . title ) ? options . title : '' ;
0 commit comments