-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathactivity.android.ts
98 lines (85 loc) · 2.65 KB
/
activity.android.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import {
Application,
setActivityCallbacks,
AndroidActivityCallbacks,
} from "@nativescript/core";
import { InAppBrowser } from "nativescript-inappbrowser";
@NativeClass()
@JavaProxy("org.nativescript.demo.MainActivity")
export class Activity extends androidx.appcompat.app.AppCompatActivity {
public isNativeScriptActivity;
private _callbacks: AndroidActivityCallbacks;
public onCreate(savedInstanceState: android.os.Bundle): void {
Application.android.init(this.getApplication());
// Set the isNativeScriptActivity in onCreate (as done in the original NativeScript activity code)
// The JS constructor might not be called because the activity is created from Android.
this.isNativeScriptActivity = true;
if (!this._callbacks) {
setActivityCallbacks(this);
}
this._callbacks.onCreate(
this,
savedInstanceState,
this.getIntent(),
super.onCreate
);
}
public onNewIntent(intent: android.content.Intent): void {
this._callbacks.onNewIntent(
this,
intent,
super.setIntent,
super.onNewIntent
);
}
public onSaveInstanceState(outState: android.os.Bundle): void {
this._callbacks.onSaveInstanceState(
this,
outState,
super.onSaveInstanceState
);
}
public onStart(): void {
this._callbacks.onStart(this, super.onStart);
// InAppBrowser initialization (Connect to the Custom Tabs service)
InAppBrowser.onStart();
}
public onStop(): void {
this._callbacks.onStop(this, super.onStop);
}
public onDestroy(): void {
this._callbacks.onDestroy(this, super.onDestroy);
}
public onPostResume(): void {
this._callbacks.onPostResume(this, super.onPostResume);
}
public onBackPressed(): void {
this._callbacks.onBackPressed(this, super.onBackPressed);
}
public onRequestPermissionsResult(
requestCode: number,
permissions: Array<string>,
grantResults: Array<number>
): void {
this._callbacks.onRequestPermissionsResult(
this,
requestCode,
permissions,
grantResults,
undefined /*TODO: Enable if needed*/
);
}
public onActivityResult(
requestCode: number,
resultCode: number,
data: android.content.Intent
): void {
this._callbacks.onActivityResult(
this,
requestCode,
resultCode,
data,
super.onActivityResult
);
}
}