0

I am trying to write an alarm clock application using JavaFXPorts and the org.javafxports.jfxmobile plugin. Beside the main view, which is a JavaFX Application, where the alarm events are set to run later. I need to load another view (another javaFx Application), which is the alarm event it self. This alarm view should be fired from a service which starts at boot time.

I have tried to do so by creating a BroadcastReciver and a Service but unfortunately I can't figure how to add another activity, which is the JavaFX Application that will be fired from the service, to the android manifest.

Currently my manifest looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.rainrobot.wake.android" android:versionCode="1" android:versionName="1.0">
        <supports-screens android:xlargeScreens="true"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

        <!-- Adding the permission -->
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

        <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="27"/>

        <application android:label="wake" android:name="android.support.multidex.MultiDexApplication" android:icon="@mipmap/ic_launcher">
            <activity android:name="io.rainrobot.wake.android.Main" android:label="Main" android:configChanges="orientation|screenSize">
                        <meta-data android:name="main.class" android:value="io.rainrobot.wake.android.Main"/>
                        <meta-data android:name="debug.port" android:value="0"/>
                        <intent-filter>
                                <action android:name="android.intent.action.MAIN"/>
                                <category android:name="android.intent.category.LAUNCHER"/>
                        </intent-filter>
            </activity>

            <activity android:name="???" android:label="Alarm event">
                        ???
                        ???
                        ???
            </activity>


            <!-- Declaring broadcast receiver for BOOT_COMPLETED event. --> 
            <receiver android:name=".Boot" android:enabled="true" android:exported="false">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED"/>
                </intent-filter>
            </receiver>

            <service    android:name=".Service" android:exported="false">
            </service>
        </application>       
</manifest>
Chaoz
  • 2,119
  • 1
  • 20
  • 39
Rb87
  • 180
  • 1
  • 9
  • Have you checked the LocalNotifications [service](https://bitbucket.org/gluon-oss/charm-down/src/default/plugins/plugin-local-notifications/src/main/java/com/gluonhq/charm/down/plugins/LocalNotificationsService.java)? That is precisely the service that will trigger a notification at a given time. The Devoxx [app](https://github.com/devoxx/MyDevoxxGluon/blob/master/DevoxxClientMobile/src/main/java/com/devoxx/util/DevoxxNotifications.java) uses it, and when the notification is received an action is performed. – José Pereda Aug 16 '18 at 08:50
  • couple of things: 1) my app is running a background service indefinitely that check a restApi if an AlarmEvent need to go off and if so trigger it (witch is a bit different from how a regular alarm app would go about creating the alarm) so my goal is to create a service that will lunch the activity. – Rb87 Aug 16 '18 at 22:40
  • 2) I am using only javaFxPorts and not com.gluonhq.charm.glisten.application.MobileApplication. so i'm not sure if i got it right but it seems to me that the devoxx app contains a lot of views to choose from and when the notification is called the app lunch and switch to the desired view, witch is different from my intent to open "another app" so if the main JavaFx app is running the alarm JavaFx app is not switching the screen rather create a new screen. there for i am trying to initialize the javafx.application.Application.start() in the same way as javafxports.android.FXActivity dose so – Rb87 Aug 16 '18 at 22:51
  • 1
    If I get it right, you want to launch a different app from the exiting one, don't you? You could use its package name, like in [here](https://stackoverflow.com/questions/3872063/launch-an-application-from-another-application-on-android). – José Pereda Aug 18 '18 at 10:07
  • yes, to be specific from a user point of view there is only one app (only one apk). but the alarm view should run from another javafx application. isn't getLaunchIntentForPackage used in conjunction with another app installed separately? – Rb87 Aug 21 '18 at 22:05
  • I was trying to figure out if i can use FXActivity or FXFragment in any way to launch this "second javafx app". not sure if its possible – Rb87 Aug 21 '18 at 22:10
  • 1
    Two JavaFX apps means two APKs. Each one with their own package name. Are you really sure you want that? Can't you use only one single application? – José Pereda Aug 21 '18 at 22:58
  • I understand, then in that case of course 2 APKs is not an option. So I think i should add the alarm view to the main app and just lunch it from there. Thanx for the patience - appreciate it very much. – Rb87 Aug 24 '18 at 14:11
  • I am assuming it is possible to pass information to the FXActivity in order to open a diffrent view then MainView, but i just realized i am not sure how or if it can be done – Rb87 Aug 24 '18 at 14:21

0 Answers0