作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 PositionService
iOS 上的 Gluon Mobile。我编写了一个在桌面上运行的小型示例应用程序,提供(按预期)虚假的位置更改,并在 Android 上运行。但是,在 iOS 模拟器上,不会调用监听器。这是代码的相关部分:
public class BasicView extends View {
private static final Logger LOGGER = Logger.getLogger(BasicView.class.getName());
final Label label;
public BasicView(String name) {
super(name);
label = new Label();
VBox controls = new VBox(15.0, label);
controls.setAlignment(Pos.CENTER);
setCenter(controls);
// get current position
Platform p = PlatformFactory.getPlatform();
PositionService ps = p.getPositionService();
outputPos(ps.getPosition());
ps.positionProperty().addListener((obs, oldPos, newPos) -> {
LOGGER.log(Level.INFO, "\nobs: {0}\noldPos: {1}\nnewPos: {2}",
new Object[]{obs, oldPos, newPos});
outputPos(newPos);
});
}
private void outputPos(Position p) {
if (p != null) {
label.setText(String.format("We are currently here: %f %f",
p.getLatitude(),
p.getLongitude()));
}
}
@Override
protected void updateAppBar(AppBar appBar) {
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> System.out.println("Menu")));
appBar.setTitleText("Basic View");
appBar.getActionItems().add(MaterialDesignIcon.SEARCH.button(e -> System.out.println("Search")));
}
}
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>location-services</string>
</array>
...
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is required to find out where you are</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is required to find out where you are</string>
Aug 27, 2016 1:37:31 PM com.gluonhq.charm.down.ios.IOSPositionService <init>
INFO: Location Manager configured with desiredAccuracy 10.00 and distanceFilter 100.00
Aug 27, 2016 1:37:31 PM com.gluonhq.charm.down.ios.IOSPositionService <init>
INFO: Telling LocationManager to start updating location.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.thomaskuenneth.gluon.positionservicedemo.PositionServiceDemo'
dependencies {
compile 'com.gluonhq:charm:3.0.0'
androidRuntime 'com.gluonhq:charm-android:3.0.0'
iosRuntime 'com.gluonhq:charm-ios:3.0.0'
desktopRuntime 'com.gluonhq:charm-desktop:3.0.0'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
compileSdkVersion = 23
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
最佳答案
我听从了 José Pereda 的建议并升级到了 Gluon Mobile 4。在以下步骤之后,我在 iPad 模拟器中看到了位置变化。因此,我建议任何遇到与我在问题中提到的相同困难的人,尝试升级。这解决了我的问题。
更新 build.gradle 如下:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.1.1'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.thomaskuenneth.gluon.positionservicedemo.PositionServiceDemo'
dependencies {
compile 'com.gluonhq:charm:4.0.1'
}
jfxmobile {
downConfig {
version '3.0.0'
plugins 'display', 'lifecycle', 'statusbar', 'storage', 'position'
}
android {
manifest = 'src/android/AndroidManifest.xml'
androidSdk = "/Users/thomas/Library/Android/sdk"
compileSdkVersion = 24
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
package com.thomaskuenneth.gluon.positionservicedemo;
import com.gluonhq.charm.down.Services;
import com.gluonhq.charm.down.plugins.Position;
import com.gluonhq.charm.down.plugins.PositionService;
import com.gluonhq.charm.glisten.control.AppBar;
import com.gluonhq.charm.glisten.mvc.View;
import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
public class BasicView extends View {
private static final Logger LOGGER = Logger.getLogger(BasicView.class.getName());
final Label label;
public BasicView(String name) {
super(name);
label = new Label();
VBox controls = new VBox(15.0, label);
controls.setAlignment(Pos.CENTER);
setCenter(controls);
Services.get(PositionService.class).ifPresent(serivce -> {
serivce.positionProperty().addListener((obs, oldPos, newPos) -> {
LOGGER.log(Level.INFO, "\nobs: {0}\noldPos: {1}\nnewPos: {2}",
new Object[]{obs, oldPos, newPos});
outputPos(newPos);
});
});
}
private void outputPos(Position p) {
if (p != null) {
label.setText(String.format("We are currently here: %f %f",
p.getLatitude(),
p.getLongitude()));
}
}
@Override
protected void updateAppBar(AppBar appBar) {
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> System.out.println("Menu")));
appBar.setTitleText("Basic View");
appBar.getActionItems().add(MaterialDesignIcon.SEARCH.button(e -> System.out.println("Search")));
}
}
<string>location-services</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
...
关于gluon-mobile - 如何在 iOS 上的 Gluon Mobile 中使用 PositionService?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39180735/
我想使用 PositionService iOS 上的 Gluon Mobile。我编写了一个在桌面上运行的小型示例应用程序,提供(按预期)虚假的位置更改,并在 Android 上运行。但是,在 iO
我是一名优秀的程序员,十分优秀!