@@ -5,12 +5,12 @@ if (typeof NSDate !== 'undefined') {
55 start = java . lang . System . currentTimeMillis ( ) ;
66}
77
8- import { Application , ApplicationEventData , UnhandledErrorEventData , DiscardedErrorEventData , AndroidActivityBundleEventData , AndroidActivityEventData , AndroidApplication , AndroidActivityNewIntentEventData , AndroidActivityResultEventData , AndroidActivityBackPressedEventData } from '@nativescript/core' ;
8+ import { AndroidActivityBackPressedEventData , AndroidActivityBundleEventData , AndroidActivityEventData , AndroidActivityNewIntentEventData , AndroidActivityResultEventData , Application , ApplicationEventData , DiscardedErrorEventData , LaunchEventData , UnhandledErrorEventData } from '@nativescript/core' ;
99
1010if ( Application . ios ) {
1111 // Observe application notifications.
1212 Application . ios . addNotificationObserver ( UIApplicationDidFinishLaunchingNotification , ( notification : NSNotification ) => {
13- console . log ( 'UIApplicationDidFinishLaunchingNotification: ' + notification ) ;
13+ console . log ( 'UIApplicationDidFinishLaunchingNotification:' , notification ) ;
1414 } ) ;
1515}
1616
@@ -19,118 +19,118 @@ Application.on(Application.displayedEvent, function (args: ApplicationEventData)
1919 global . isDisplayedEventFired = true ;
2020
2121 if ( args . android ) {
22- // For Android applications, args.android is an Android activity class.
23- console . log ( 'Displayed Activity: ' + args . android ) ;
22+ // For Android applications, args.activity is an Android activity class.
23+ console . log ( 'Displayed Activity:' , ( args as AndroidActivityEventData ) . activity ) ;
2424 } else if ( args . ios ) {
2525 // For iOS applications, args.ios is UIApplication.
26- console . log ( 'Displayed UIApplication: ' + args . ios ) ;
26+ console . log ( 'Displayed UIApplication:' , args . ios ) ;
2727 }
2828} ) ;
2929
30- Application . on ( Application . launchEvent , function ( args : ApplicationEventData ) {
30+ Application . on ( Application . launchEvent , function ( args : LaunchEventData ) {
3131 if ( args . android ) {
3232 // For Android applications, args.android is an android.content.Intent class.
33- console . log ( 'Launched Android application with the following intent: ' + args . android + '.' ) ;
33+ console . log ( 'Launched Android application with the following intent:' , args . android ) ;
3434 } else if ( args . ios !== undefined ) {
3535 // For iOS applications, args.ios is NSDictionary (launchOptions).
36- console . log ( 'Launched iOS application with options: ' + args . ios ) ;
36+ console . log ( 'Launched iOS application with options:' , args . ios ) ;
3737 }
3838} ) ;
3939
4040Application . on ( Application . suspendEvent , function ( args : ApplicationEventData ) {
4141 if ( args . android ) {
4242 // For Android applications, args.android is an Android activity class.
43- console . log ( 'Suspend Activity: ' + args . android ) ;
43+ console . log ( 'Suspend Activity:' , args . android ) ;
4444 } else if ( args . ios ) {
4545 // For iOS applications, args.ios is UIApplication.
46- console . log ( 'Suspend UIApplication: ' + args . ios ) ;
46+ console . log ( 'Suspend UIApplication:' , args . ios ) ;
4747 }
4848} ) ;
4949
5050Application . on ( Application . resumeEvent , function ( args : ApplicationEventData ) {
5151 if ( args . android ) {
5252 // For Android applications, args.android is an Android activity class.
53- console . log ( 'Resume Activity: ' + args . android ) ;
53+ console . log ( 'Resume Activity:' , args . android ) ;
5454 } else if ( args . ios ) {
5555 // For iOS applications, args.ios is UIApplication.
56- console . log ( 'Resume UIApplication: ' + args . ios ) ;
56+ console . log ( 'Resume UIApplication:' , args . ios ) ;
5757 }
5858} ) ;
5959
6060Application . on ( Application . exitEvent , function ( args : ApplicationEventData ) {
6161 if ( args . android ) {
6262 // For Android applications, args.android is an Android activity class.
63- console . log ( 'Exit Activity: ' + args . android ) ;
63+ console . log ( 'Exit Activity:' , args . android ) ;
6464 } else if ( args . ios ) {
6565 // For iOS applications, args.ios is UIApplication.
66- console . log ( 'Exit UIApplication: ' + args . ios ) ;
66+ console . log ( 'Exit UIApplication:' , args . ios ) ;
6767 }
6868} ) ;
6969
7070Application . on ( Application . lowMemoryEvent , function ( args : ApplicationEventData ) {
7171 if ( args . android ) {
7272 // For Android applications, args.android is an Android activity class.
73- console . log ( 'Low Memory: ' + args . android ) ;
73+ console . log ( 'Low Memory:' , args . android ) ;
7474 } else if ( args . ios ) {
7575 // For iOS applications, args.ios is UIApplication.
76- console . log ( 'Low Memory: ' + args . ios ) ;
76+ console . log ( 'Low Memory:' , args . ios ) ;
7777 }
7878} ) ;
7979
8080// Error events.
8181Application . on ( Application . uncaughtErrorEvent , function ( args : UnhandledErrorEventData ) {
82- console . log ( 'NativeScriptError: ' + args . error ) ;
83- console . log ( ( < any > args . error ) . nativeException || ( < any > args . error ) . nativeError ) ;
84- console . log ( ( < any > args . error ) . stackTrace || ( < any > args . error ) . stack ) ;
82+ console . log ( 'NativeScriptError:' , args . error ) ;
83+ console . log ( ( < any > args . error ) . nativeException ?? ( < any > args . error ) . nativeError ) ;
84+ console . log ( ( < any > args . error ) . stackTrace ?? ( < any > args . error ) . stack ) ;
8585} ) ;
8686
8787Application . on ( Application . discardedErrorEvent , function ( args : DiscardedErrorEventData ) {
88- console . log ( '[Discarded] NativeScriptError: ' + args . error ) ;
89- console . log ( ( < any > args . error ) . nativeException || ( < any > args . error ) . nativeError ) ;
90- console . log ( ( < any > args . error ) . stackTrace || ( < any > args . error ) . stack ) ;
88+ console . log ( '[Discarded] NativeScriptError:' , args . error ) ;
89+ console . log ( ( < any > args . error ) . nativeException ?? ( < any > args . error ) . nativeError ) ;
90+ console . log ( ( < any > args . error ) . stackTrace ?? ( < any > args . error ) . stack ) ;
9191} ) ;
9292
9393// Android activity events.
9494if ( Application . android ) {
95- Application . android . on ( AndroidApplication . activityCreatedEvent , function ( args : AndroidActivityBundleEventData ) {
96- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity + ', Bundle: ' + args . bundle ) ;
95+ Application . android . on ( Application . android . activityCreatedEvent , function ( args : AndroidActivityBundleEventData ) {
96+ console . log ( 'Event: ' + args . eventName + ', Activity:' , args . activity , ', Bundle:' , args . bundle ) ;
9797 } ) ;
9898
99- Application . android . on ( AndroidApplication . activityDestroyedEvent , function ( args : AndroidActivityEventData ) {
100- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity ) ;
99+ Application . android . on ( Application . android . activityDestroyedEvent , function ( args : AndroidActivityEventData ) {
100+ console . log ( 'Event: ' + args . eventName + ', Activity: ' , args . activity ) ;
101101 } ) ;
102102
103- Application . android . on ( AndroidApplication . activityStartedEvent , function ( args : AndroidActivityEventData ) {
104- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity ) ;
103+ Application . android . on ( Application . android . activityStartedEvent , function ( args : AndroidActivityEventData ) {
104+ console . log ( 'Event: ' + args . eventName + ', Activity:' , args . activity ) ;
105105 } ) ;
106106
107- Application . android . on ( AndroidApplication . activityPausedEvent , function ( args : AndroidActivityEventData ) {
108- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity ) ;
107+ Application . android . on ( Application . android . activityPausedEvent , function ( args : AndroidActivityEventData ) {
108+ console . log ( 'Event: ' + args . eventName + ', Activity:' , args . activity ) ;
109109 } ) ;
110110
111- Application . android . on ( AndroidApplication . activityResumedEvent , function ( args : AndroidActivityEventData ) {
112- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity ) ;
111+ Application . android . on ( Application . android . activityResumedEvent , function ( args : AndroidActivityEventData ) {
112+ console . log ( 'Event: ' + args . eventName + ', Activity:' , args . activity ) ;
113113 } ) ;
114114
115- Application . android . on ( AndroidApplication . activityStoppedEvent , function ( args : AndroidActivityEventData ) {
116- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity ) ;
115+ Application . android . on ( Application . android . activityStoppedEvent , function ( args : AndroidActivityEventData ) {
116+ console . log ( 'Event: ' + args . eventName + ', Activity:' , args . activity ) ;
117117 } ) ;
118118
119- Application . android . on ( AndroidApplication . saveActivityStateEvent , function ( args : AndroidActivityBundleEventData ) {
120- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity + ', Bundle: ' + args . bundle ) ;
119+ Application . android . on ( Application . android . saveActivityStateEvent , function ( args : AndroidActivityBundleEventData ) {
120+ console . log ( 'Event: ' + args . eventName + ', Activity:' , args . activity , ', Bundle:' , args . bundle ) ;
121121 } ) ;
122122
123- Application . android . on ( AndroidApplication . activityResultEvent , function ( args : AndroidActivityResultEventData ) {
124- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity + ', requestCode: ' + args . requestCode + ', resultCode: ' + args . resultCode + ', Intent: ' + args . intent ) ;
123+ Application . android . on ( Application . android . activityResultEvent , function ( args : AndroidActivityResultEventData ) {
124+ console . log ( 'Event:' , args . eventName , ', Activity:' , args . activity , ', requestCode: ' , args . requestCode , ', resultCode: ' , args . resultCode , ', Intent: ' , args . intent ) ;
125125 } ) ;
126126
127- Application . android . on ( AndroidApplication . activityBackPressedEvent , function ( args : AndroidActivityBackPressedEventData ) {
128- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity ) ;
127+ Application . android . on ( Application . android . activityBackPressedEvent , function ( args : AndroidActivityBackPressedEventData ) {
128+ console . log ( 'Event:' , args . eventName , ', Activity:' , args . activity ) ;
129129 // Set args.cancel = true to cancel back navigation and do something custom.
130130 } ) ;
131131
132- Application . android . on ( AndroidApplication . activityNewIntentEvent , function ( args : AndroidActivityNewIntentEventData ) {
133- console . log ( 'Event: ' + args . eventName + ', Activity: ' + args . activity + ', Intent: ' + args . intent ) ;
132+ Application . android . on ( Application . android . activityNewIntentEvent , function ( args : AndroidActivityNewIntentEventData ) {
133+ console . log ( 'Event: ' , args . eventName , ', Activity:' , args . activity , ', Intent:' , args . intent ) ;
134134 } ) ;
135135}
136136
0 commit comments