Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,11 @@ Next, modify the activity in `App_Resources/Android/src/main/AndroidManifest.xml
android:configChanges="keyboardHidden|orientation|screenSize">
```

To include the new Activity in the build, make sure it's added to the `webpack.config.js` with the following:
To include the new Activity in the build, make sure it's configured with the bundler you're using (webpack or vite):

```js
::: code-group

```js [webpack]
const webpack = require('@nativescript/webpack')

module.exports = (env) => {
Expand All @@ -502,6 +504,31 @@ module.exports = (env) => {
}
```

```ts [vite]
import { defineConfig } from 'vite';
import { typescriptConfig, appComponentsPlugin } from '@nativescript/vite';

export default defineConfig(({ mode }) => {
const config = typescriptConfig({ mode });

// Register custom Android Activity and Application classes
config.plugins!.push(
appComponentsPlugin({
appComponents: [
// include any your app needs
'./src/custom-activity.android.ts',
'./src/custom-application.android.ts'
],
platform: 'android'
})
);

return config;
});
```

:::

## Implementing Kotlin and Java interfaces

The next example shows how to implement an interface in Kotlin/Java with NativeScript. The main difference between inheriting classes and implementing interfaces in NativeScript is the use of the `extend` keyword. Implement an interface is done by passing the implementation object to the interface constructor function. The syntax is identical to [Java Anonymous Classes](https://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html).
Expand Down
Loading