@@ -5,12 +5,12 @@ if (typeof NSDate !== 'undefined') {
5
5
start = java . lang . System . currentTimeMillis ( ) ;
6
6
}
7
7
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' ;
9
9
10
10
if ( Application . ios ) {
11
11
// Observe application notifications.
12
12
Application . ios . addNotificationObserver ( UIApplicationDidFinishLaunchingNotification , ( notification : NSNotification ) => {
13
- console . log ( 'UIApplicationDidFinishLaunchingNotification: ' + notification ) ;
13
+ console . log ( 'UIApplicationDidFinishLaunchingNotification:' , notification ) ;
14
14
} ) ;
15
15
}
16
16
@@ -19,118 +19,118 @@ Application.on(Application.displayedEvent, function (args: ApplicationEventData)
19
19
global . isDisplayedEventFired = true ;
20
20
21
21
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 ) ;
24
24
} else if ( args . ios ) {
25
25
// For iOS applications, args.ios is UIApplication.
26
- console . log ( 'Displayed UIApplication: ' + args . ios ) ;
26
+ console . log ( 'Displayed UIApplication:' , args . ios ) ;
27
27
}
28
28
} ) ;
29
29
30
- Application . on ( Application . launchEvent , function ( args : ApplicationEventData ) {
30
+ Application . on ( Application . launchEvent , function ( args : LaunchEventData ) {
31
31
if ( args . android ) {
32
32
// 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 ) ;
34
34
} else if ( args . ios !== undefined ) {
35
35
// 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 ) ;
37
37
}
38
38
} ) ;
39
39
40
40
Application . on ( Application . suspendEvent , function ( args : ApplicationEventData ) {
41
41
if ( args . android ) {
42
42
// For Android applications, args.android is an Android activity class.
43
- console . log ( 'Suspend Activity: ' + args . android ) ;
43
+ console . log ( 'Suspend Activity:' , args . android ) ;
44
44
} else if ( args . ios ) {
45
45
// For iOS applications, args.ios is UIApplication.
46
- console . log ( 'Suspend UIApplication: ' + args . ios ) ;
46
+ console . log ( 'Suspend UIApplication:' , args . ios ) ;
47
47
}
48
48
} ) ;
49
49
50
50
Application . on ( Application . resumeEvent , function ( args : ApplicationEventData ) {
51
51
if ( args . android ) {
52
52
// For Android applications, args.android is an Android activity class.
53
- console . log ( 'Resume Activity: ' + args . android ) ;
53
+ console . log ( 'Resume Activity:' , args . android ) ;
54
54
} else if ( args . ios ) {
55
55
// For iOS applications, args.ios is UIApplication.
56
- console . log ( 'Resume UIApplication: ' + args . ios ) ;
56
+ console . log ( 'Resume UIApplication:' , args . ios ) ;
57
57
}
58
58
} ) ;
59
59
60
60
Application . on ( Application . exitEvent , function ( args : ApplicationEventData ) {
61
61
if ( args . android ) {
62
62
// For Android applications, args.android is an Android activity class.
63
- console . log ( 'Exit Activity: ' + args . android ) ;
63
+ console . log ( 'Exit Activity:' , args . android ) ;
64
64
} else if ( args . ios ) {
65
65
// For iOS applications, args.ios is UIApplication.
66
- console . log ( 'Exit UIApplication: ' + args . ios ) ;
66
+ console . log ( 'Exit UIApplication:' , args . ios ) ;
67
67
}
68
68
} ) ;
69
69
70
70
Application . on ( Application . lowMemoryEvent , function ( args : ApplicationEventData ) {
71
71
if ( args . android ) {
72
72
// For Android applications, args.android is an Android activity class.
73
- console . log ( 'Low Memory: ' + args . android ) ;
73
+ console . log ( 'Low Memory:' , args . android ) ;
74
74
} else if ( args . ios ) {
75
75
// For iOS applications, args.ios is UIApplication.
76
- console . log ( 'Low Memory: ' + args . ios ) ;
76
+ console . log ( 'Low Memory:' , args . ios ) ;
77
77
}
78
78
} ) ;
79
79
80
80
// Error events.
81
81
Application . 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 ) ;
85
85
} ) ;
86
86
87
87
Application . 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 ) ;
91
91
} ) ;
92
92
93
93
// Android activity events.
94
94
if ( 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 ) ;
97
97
} ) ;
98
98
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 ) ;
101
101
} ) ;
102
102
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 ) ;
105
105
} ) ;
106
106
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 ) ;
109
109
} ) ;
110
110
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 ) ;
113
113
} ) ;
114
114
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 ) ;
117
117
} ) ;
118
118
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 ) ;
121
121
} ) ;
122
122
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 ) ;
125
125
} ) ;
126
126
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 ) ;
129
129
// Set args.cancel = true to cancel back navigation and do something custom.
130
130
} ) ;
131
131
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 ) ;
134
134
} ) ;
135
135
}
136
136
0 commit comments