Wie kann ich Android-Benachrichtigungen in Gluon verwenden? Ich habe den folgenden Code verwendet, aber die Benachrichtigung wird nicht ausgeführt. Vielleicht findet es den LocalNotification Service nicht?Gluon android Benachrichtigung läuft nicht
Services.get(LocalNotificationsService.class).ifPresent(service
->
{
service.getNotifications().add(new Notification(
notificationId, "Sample Notification Text",
ZonedDateTime.now().plusSeconds(10),()
->
{
Alert alert = new Alert(AlertType.INFORMATION,
"You have been notified!");
Platform.runLater(() -> alert.showAndWait());
}));
});
manifiest:
<activity android:name="javafxports.android.FXActivity" android:label="GluonApplication1" android:configChanges="orientation|screenSize">
<meta-data android:name="main.class" android:value="com.gluonapplication1.GluonApplication1"/>
<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="com.gluonhq.impl.charm.down.plugins.android.NotificationActivity"
android:parentActivityName="javafxports.android.FXActivity">
<meta-data android:name="android.support.PARENT_ACTIVITY"
android:value="javafxports.android.FXActivity"/>
</activity>
<receiver android:name="com.gluonhq.impl.charm.down.plugins.android.AlarmReceiver" />
<service
android:name="com.gluonapplication1.MyIntentService"
android:exported="false">
</service>
EDIT
Abhängigkeiten in der build.gradle
-Datei enthalten:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.gluonhq:charm:4.2.0'
compile 'com.gluonhq:charm-down-common:2.0.1'
compile group: 'com.gluonhq', name: 'charm-down-plugin-local-notifications', version: '3.1.0'
compile 'org.apache.commons:commons-lang3:3.5'
desktopRuntime 'org.xerial:sqlite-jdbc:3.15.1'
androidRuntime 'org.sqldroid:sqldroid:1.0.3'
}
Können Sie angeben, was nicht funktioniert für Sie? Ich habe gerade Ihren Code getestet und es funktioniert gut für mich (ich habe den Dienst nur aus dem Manifest entfernt). Stellen Sie sicher, dass Sie "local-notifications" zur Liste der Plugins in Ihrer build.gradle-Datei hinzufügen. –
Ich habe Kompiliergruppe hinzugefügt: 'com.gluonhq', Name: 'Charm-Down-Plugin-lokale-Benachrichtigungen', Version: '3.1.0', aber es funktioniert nicht – user2880318
Sie müssen es nicht hinzufügen, das Plugin wird TU es für dich. Veröffentlichen Sie Ihre 'build.gradle' Datei, und überprüfen Sie, ob Sie in Ihren Abhängigkeiten die' charm-down-plugin-local-notifications-android-3.1.0.jar' haben. –