Skip to content

Commit 36243f8

Browse files
committed
fix: replace deprecated usages of androidApp.context
1 parent bcc68c3 commit 36243f8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/internal/activity-recognition/recognizers/abstract-manager.android.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { RecognizerManager } from "./recognizer-manager";
22
import { hasPermission, requestPermission } from "nativescript-permissions";
33
import { android as androidApp } from "@nativescript/core/application";
4+
import { Utils } from "@nativescript/core";
45

56
import { StartOptions } from "./index";
67

@@ -56,7 +57,7 @@ export abstract class AndroidAbstractRecognizerManager
5657
}
5758

5859
const task = this.handleStart(
59-
androidApp.context,
60+
Utils.android.getApplicationContext(),
6061
this.getPendingIntent(),
6162
options
6263
);
@@ -69,7 +70,7 @@ export abstract class AndroidAbstractRecognizerManager
6970
}
7071

7172
const pendingIntent = this.getPendingIntent();
72-
const task = this.handleStop(androidApp.context, pendingIntent);
73+
const task = this.handleStop(Utils.android.getApplicationContext(), pendingIntent);
7374

7475
pendingIntent.cancel();
7576
this.pendingIntent = null;
@@ -90,7 +91,7 @@ export abstract class AndroidAbstractRecognizerManager
9091

9192
private isUp(): boolean {
9293
const pendingIntent = PendingIntent.getBroadcast(
93-
androidApp.context,
94+
Utils.android.getApplicationContext(),
9495
0,
9596
this.getReceiverIntent(),
9697
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
102103
if (!this.pendingIntent) {
103104
const receiverIntent = this.getReceiverIntent();
104105
this.pendingIntent = PendingIntent.getBroadcast(
105-
androidApp.context,
106+
Utils.android.getApplicationContext(),
106107
0,
107108
receiverIntent,
108109
android.os.Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_MUTABLE : 0
@@ -112,7 +113,7 @@ export abstract class AndroidAbstractRecognizerManager
112113
}
113114

114115
private getReceiverIntent(): Intent {
115-
return new Intent(androidApp.context, this.receiver);
116+
return new Intent(Utils.android.getApplicationContext(), this.receiver);
116117
}
117118
}
118119

@@ -121,7 +122,7 @@ const CONNECTION_RESULT_SUCCESS = 0;
121122
function isGooglePlayServicesAvailable() {
122123
return (
123124
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
124-
androidApp.context
125+
Utils.android.getApplicationContext()
125126
) === CONNECTION_RESULT_SUCCESS
126127
);
127128
}

0 commit comments

Comments
 (0)