2016-12-01 15 views
1

グルーオンでアンドロイド通知を使用するにはどうすればよいですか? 以下のコードを使用しましたが、通知は実行されません。 LocalNotificationサービスが見つからないことがありますか?グロンアンドロイド通知が実行されない

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:あなたはアンドロイドのものを追加していない、あなたの依存関係のリストに基づいて

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' 
} 
+0

あなたはあなたのために働いていないものを指定することはできますか?私はちょうどあなたのコードをテストして、それは私のためにうまくいく(私はマニフェストからサービスを削除した)。 build.gradleファイルのプラグインリストに '' local-notifications''を追加してください。 –

+0

コンパイルグループ 'com.gluonhq'、名前: 'charm-down-plugin-local-notifications'、バージョン: '3.1.0'を追加しましたが、動作しません – user2880318

+0

プラグインを追加する必要はありません。自分のためにやれ。あなたの 'build.gradle'ファイルを投稿し、あなたの依存関係に' charm-down-plugin-local-notifications-android-3.1.0.jar'があるかどうかを確認してください。 –

答えて

1

依存関係がbuild.gradleファイルに含ま

<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 、あなたは新しいdownConfig設定を使用していませんnにCharm Downプラグインを含めます。 jfxmobileプラグイン1.1.0+を使用してビルドスクリプトの変更をhereと読んでください。少なくともこれを含めるように

あなたのbuild.gradleファイルを変更する必要があります:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'org.javafxports:jfxmobile-plugin:1.2.0' 
    } 
} 

apply plugin: 'org.javafxports.jfxmobile' 

repositories { 
    jcenter() 
    maven { 
     url 'http://nexus.gluonhq.com/nexus/content/repositories/releases' 
    } 
} 

mainClassName = 'your.main.class.Name' 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.gluonhq:charm:4.2.0' 
    compile 'org.apache.commons:commons-lang3:3.5' 
    desktopRuntime 'org.xerial:sqlite-jdbc:3.15.1' 
    androidRuntime 'org.sqldroid:sqldroid:1.0.3' 
} 

jfxmobile { 
    downConfig { 
     version = '3.1.0' 
     // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead 
     plugins 'display', 'lifecycle', 'local-notifications', 'statusbar', 'storage' 
    } 
    android { 
     manifest = 'src/android/AndroidManifest.xml' 
    } 
    ios { 
     infoPList = file('src/ios/Default-Info.plist') 
     forceLinkClasses = [ 
       'com.gluonhq.**.*', 
       'javax.annotations.**.*', 
       'javax.inject.**.*', 
       'javax.json.**.*', 
       'org.glassfish.json.**.*' 
     ] 
    } 
} 
関連する問題