Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit ac6295c

Browse files
committed
test(AngularApp): extend android activity
1 parent b271bbb commit ac6295c

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

demo/AngularApp/app/App_Resources/Android/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
android:theme="@style/AppTheme">
2727

2828
<activity
29-
android:name="com.tns.NativeScriptActivity"
29+
android:name="org.myApp.MainActivity"
3030
android:label="@string/title_activity_kimera"
3131
android:configChanges="keyboardHidden|orientation|screenSize"
3232
android:theme="@style/LaunchScreenTheme">
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {setActivityCallbacks, AndroidActivityCallbacks} from "ui/frame";
2+
3+
@JavaProxy("org.myApp.MainActivity")
4+
class Activity extends android.app.Activity {
5+
private _callbacks: AndroidActivityCallbacks;
6+
7+
protected onCreate(savedInstanceState: android.os.Bundle): void {
8+
if (!this._callbacks) {
9+
setActivityCallbacks(this);
10+
}
11+
12+
this._callbacks.onCreate(this, savedInstanceState, super.onCreate);
13+
}
14+
15+
protected onSaveInstanceState(outState: android.os.Bundle): void {
16+
this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState);
17+
}
18+
19+
protected onStart(): void {
20+
this._callbacks.onStart(this, super.onStart);
21+
}
22+
23+
protected onStop(): void {
24+
this._callbacks.onStop(this, super.onStop);
25+
}
26+
27+
protected onDestroy(): void {
28+
this._callbacks.onDestroy(this, super.onDestroy);
29+
}
30+
31+
public onBackPressed(): void {
32+
this._callbacks.onBackPressed(this, super.onBackPressed);
33+
}
34+
35+
public onRequestPermissionsResult(requestCode: number, permissions: Array<String>, grantResults: Array<number>): void {
36+
this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
37+
}
38+
39+
protected onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void {
40+
this._callbacks.onActivityResult(this, requestCode, resultCode, data, super.onActivityResult);
41+
}
42+
}

demo/AngularApp/webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = env => {
1616
const appComponents = [
1717
"tns-core-modules/ui/frame",
1818
"tns-core-modules/ui/frame/activity",
19+
resolve(__dirname, "app/activity.android.ts"),
1920
];
2021

2122
const platform = env && (env.android && "android" || env.ios && "ios");

0 commit comments

Comments
 (0)