android-js / androidjs

Platform to build android app using node js
MIT License
462 stars 109 forks source link

️‍🔥 How/Where can we modify AndroidJS java base or extend androidjs react native layer through npm react native addons ? #304

Open LAGENCECREE opened 1 year ago

LAGENCECREE commented 1 year ago

How/Where can we modify AndroidJS java base or extend androidjs react native layer through npm react native addons ?

for instance i want to make the app autostart at system boot

i have two options

1- using the addon : npm react-native-autostart

or 2- work on native layer trought manifest and classes :

<manifest /****/ >
    <application /***/ >
       /*****/
        <receiver android:name=".AutoStartupReceiver" android:enabled="true" android:exported="true" android:label="AutoStartupReceiver" >
            <intent-filter >
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>
    </application>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
/****/
</manifest>

and add a class to the project

public class AutoStartupReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent launchIntent = new Intent(context, MainActivity.class);
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(launchIntent);
    }
}

the question:

How/Where can we modify AndroidJS java base or extend androidjs react native layer through npm react native addons ?

i found android sdk -> smali files... android builder -> ok to modify the manifest but not the java files

i found project like https://github.com/android-js/androidjs-core-webview or https://github.com/android-js/androidjs-core-react-native

but i dont understand if they are already part of the webview created by default androidjs install