Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit ba89c28

Browse files
committed
test(TypeScriptApp): extend android activity
1 parent c2d10db commit ba89c28

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

‎demo/TypeScriptApp/app/App_Resources/Android/AndroidManifest.xml‎

Lines changed: 1 addition & 1 deletion
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">
Lines changed: 42 additions & 0 deletions
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/TypeScriptApp/webpack.config.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = env => {
1414
const appComponents = [
1515
"tns-core-modules/ui/frame",
1616
"tns-core-modules/ui/frame/activity",
17+
resolve(__dirname, "app/activity.android.ts"),
1718
];
1819

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /