1
1
import { RecognizerManager } from "./recognizer-manager" ;
2
2
import { hasPermission , requestPermission } from "nativescript-permissions" ;
3
3
import { android as androidApp } from "@nativescript/core/application" ;
4
+ import { Utils } from "@nativescript/core" ;
4
5
5
6
import { StartOptions } from "./index" ;
6
7
@@ -56,7 +57,7 @@ export abstract class AndroidAbstractRecognizerManager
56
57
}
57
58
58
59
const task = this . handleStart (
59
- androidApp . context ,
60
+ Utils . android . getApplicationContext ( ) ,
60
61
this . getPendingIntent ( ) ,
61
62
options
62
63
) ;
@@ -69,7 +70,7 @@ export abstract class AndroidAbstractRecognizerManager
69
70
}
70
71
71
72
const pendingIntent = this . getPendingIntent ( ) ;
72
- const task = this . handleStop ( androidApp . context , pendingIntent ) ;
73
+ const task = this . handleStop ( Utils . android . getApplicationContext ( ) , pendingIntent ) ;
73
74
74
75
pendingIntent . cancel ( ) ;
75
76
this . pendingIntent = null ;
@@ -90,7 +91,7 @@ export abstract class AndroidAbstractRecognizerManager
90
91
91
92
private isUp ( ) : boolean {
92
93
const pendingIntent = PendingIntent . getBroadcast (
93
- androidApp . context ,
94
+ Utils . android . getApplicationContext ( ) ,
94
95
0 ,
95
96
this . getReceiverIntent ( ) ,
96
97
android . os . Build . VERSION . SDK_INT >= 23 ? PendingIntent . FLAG_NO_CREATE | PendingIntent . FLAG_IMMUTABLE : PendingIntent . FLAG_NO_CREATE
@@ -102,7 +103,7 @@ export abstract class AndroidAbstractRecognizerManager
102
103
if ( ! this . pendingIntent ) {
103
104
const receiverIntent = this . getReceiverIntent ( ) ;
104
105
this . pendingIntent = PendingIntent . getBroadcast (
105
- androidApp . context ,
106
+ Utils . android . getApplicationContext ( ) ,
106
107
0 ,
107
108
receiverIntent ,
108
109
android . os . Build . VERSION . SDK_INT >= 31 ? PendingIntent . FLAG_MUTABLE : 0
@@ -112,7 +113,7 @@ export abstract class AndroidAbstractRecognizerManager
112
113
}
113
114
114
115
private getReceiverIntent ( ) : Intent {
115
- return new Intent ( androidApp . context , this . receiver ) ;
116
+ return new Intent ( Utils . android . getApplicationContext ( ) , this . receiver ) ;
116
117
}
117
118
}
118
119
@@ -121,7 +122,7 @@ const CONNECTION_RESULT_SUCCESS = 0;
121
122
function isGooglePlayServicesAvailable ( ) {
122
123
return (
123
124
GoogleApiAvailability . getInstance ( ) . isGooglePlayServicesAvailable (
124
- androidApp . context
125
+ Utils . android . getApplicationContext ( )
125
126
) === CONNECTION_RESULT_SUCCESS
126
127
) ;
127
128
}
0 commit comments