我建立了一个在启动时采样GPS的应用程序.您可能知道,在Android M及更高版本的运行时期间会请求权限.
所以,在我的情况下,我开始检查是否需要权限,如下所示:
private void permissionForAndroidM()
{
if (Build.VERSION.SDK_INT > 22) {
String[] allPermissionNeeded = {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO};
List<String> permissionNeeded = new ArrayList<>();
for (String permission : allPermissionNeeded)
if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED)
permissionNeeded.add(permission);
if (permissionNeeded.size() > 0) {
requestPermissions(permissionNeeded.toArray(new String[0]), 0);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但 Android继续运行代码并要求GPS数据(=崩溃,因为用户不接受权限请求).
我找到了很多关于等待用户输入的解决方案(比如使用DialogInterface.OnClickListener,链接,但在这种情况下它无法实现,因为我没有创建对话框).
最重要的是,问题:如何从Android权限对话框中等待用户回答?
我花了很多时间在网上搜索,但没有任何帮助我..
我使用QML构建GUI,我希望他没有框架.
我试着像这样改变我的main.cpp:
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/RR_QML/main.qml"));
viewer.setFlags(Qt::FramelessWindowHint | Qt::Window);
viewer.showExpanded();
return app.exec();
}
Run Code Online (Sandbox Code Playgroud)
我还尝试更改main.qml文件:
Window
{
id: rootWindow
flags: Qt.FramelessWindowHint | Qt.Window
// my qml code here
}
Run Code Online (Sandbox Code Playgroud)
但没什么用.
我很乐意提供任何帮助,谢谢!
我合作:
我们正在尝试将 Spring Boot 版本升级到 2.6.0,并面临“Spring Boot [2.6.0] 与此 Spring Cloud 发行版不兼容”(运行集成测试时)。
另外的
spring-cloud.version = 2020.0.4
我们使用 org.springframework.cloud (spring-cloud-context 和 spring-cloud-commons)3.0.4
并且在 pom 中(也)有这个块:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>2.2.10.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>bcprov-jdk15on</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>spring-cloud-starter</artifactId>
<groupId>org.springframework.cloud</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<version>3.0.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
实际上我没有在Spring 文档中找到Spring Cloud 和 Spring Boot 2.6.0 之间的兼容性,这听起来很奇怪,但是我是否需要等待最新的 Spring Cloud 版本或者我可以击败它?
附:
软件开发工具包:Java 8
其他尝试(每个都单独尝试):
spring.profiles.active=nativespring.cloud.compatibility-verifier.enabled=false我最近在WPF,当我学习我遇到的奇怪问题的材料.
我构建了一个按钮,包含带有文本块的图层,我想要识别用户点击"按钮本身,'第一','第二或'第三'的位置(我输出一条消息).

一切正常,但当用户点击左键(只有中间或右键)时,按钮不会引发事件.
所以我的问题:为什么当我用鼠标左键按下按钮时我没有收到消息框(我收到带有其他鼠标按钮的消息框)?
XAML:
<Button Margin="145,152,144,102" Padding="5,5,5,5" HorizontalAlignment="Center" VerticalAlignment="Center" MouseDown="Button_MouseDown" Height="57" Width="214">
<WrapPanel>
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center"></WrapPanel>
<TextBlock Foreground="Black" FontSize="24" MouseDown="TextBlockFirst_MouseDown" >First </TextBlock>
<TextBlock Foreground="Red" FontSize="24" MouseDown="TextBlockSecond_MouseDown">Second </TextBlock>
<TextBlock Foreground="Blue" FontSize="24" MouseDown="TextBlockThird_MouseDown" >Third </TextBlock>
</WrapPanel>
</Button>
Run Code Online (Sandbox Code Playgroud)
码:
private void TextBlockFirst_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("You click on first");
}
private void TextBlockSecond_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("You click on second");
}
private void TextBlockThird_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("You click on third");
}
private void Button_MouseDown(object sender, MouseButtonEventArgs e)
{ …Run Code Online (Sandbox Code Playgroud) 在我的工作中,application.yml 中的字段是动态的,每个开发人员都有另一个(动态)配置。因此,我们有与我们所有人相关的一般 yml 部分(并且不时更新)和“私人资料”
像这样:
spring:
profiles: default
configuration:
...
...
spring:
profiles: development1
configuration: ...
spring:
profiles: development2
configuration: ...
Run Code Online (Sandbox Code Playgroud)
我们在这方面有“小”问题(错误、冲突等),我们正在寻找解决方案。我为每个开发人员考虑单独的 yml 文件,例如:
spring:
profiles: development1
configuration:
yml-file: app_dev1.yml
spring:
profiles: development2
configuration:
yml-file: app_dev2.yml
Run Code Online (Sandbox Code Playgroud)
但没有找到如何做到这一点......
会很高兴知道它是否可以完成?(或者您有另一种方法来分隔我们之间的 yml)。
我们不想设置带有注释的应用程序 yaml(再次出现 git 问题..),例如Environment Variables...
这不是真正的编码问题,但我一直坚持下去。我在 Intelliji 中启动新的 Java 项目并使用 JUnit5 添加测试。在这个测试中,我使用FakeSftpServerRule github 库的@Role注释。
我在 pom 文件中添加了所有我能想到的 jupiter 依赖项:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是初始化假ftp的方法:
@Rule
public final FakeSftpServerRule fakeSftpServer = new FakeSftpServerRule()
.addUser(username, password)
.setPort(port);
Run Code Online (Sandbox Code Playgroud)
而且我正在使用常规的其他属性,例如@BeforeAll和@Test...
运行测试会抛出这个错误:
发生内部错误。org.junit.platform.commons.JUnitException:ID 为“junit-vintage”的 TestEngine 未能在 org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:189) 的 org.junit.platform 上发现测试。 launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:168) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java: 69) 在 com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) 在 com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) 在 com.intellij.rt.junit .JUnitStarter.main(JUnitStarter.java:58) …
我正在编写应该在Android L和M上运行的应用程序
您可能知道,对于Android M,需要在代码中询问写入\从外部存储(sdcard)读取的权限,如下所示:
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)==
PackageManager.PERMISSION_GRANTED)
requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
Run Code Online (Sandbox Code Playgroud)
但是,我遇到了一个问题,因为调用checkSelfPermission需要API级别23(而不是22,因为我需要Lollipop支持).
我试图添加,@TargetApi(Build.VERSION_CODES.MNC)但我面临另一个问题 -"Cannot resolved symbol MNC"
那么问题是,我如何编写代码来保存sdcard中的文件,Lollipop和Marshmallow?
编辑:项目结构设置:
编译Sdk版本:API 23:Android 5.X(MNC
Min Sdk版本:API 22:Android 5.1(Lollipop)
Target Sdk版本:API 23:Android 5.X(MNC)
谢谢
我开始使用 sql 并面临分层查询。同时我成功地使用connect by prior命令选择行但未能更新。这是我的更新查询:
update HTABLE set status = 'INACTIVE'
WHERE STATUS <> 'CLOSE'
Connect by prior PARENT_ID=ID start with PARENT_ID=12345;
Run Code Online (Sandbox Code Playgroud)
我得到SQL Error: ORA-00933: SQL command not properly ended并将很高兴知道如何使用分层更新表..
谢谢!
编辑
我也试图把where条件放在start with, not help 中:
update HTABLE set status = 'INACTIVE'
Connect by prior PARENT_ID=ID start with PARENT_ID=12345 AND STATUS <> 'CLOSE';
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 getSystemClipboard 将文本复制到基于 java Web 的应用程序中的剪贴板:
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Run Code Online (Sandbox Code Playgroud)
但我遇到了java.awt.HeadlessException异常,我不明白为什么,特别是因为根据文档,这个异常与调用缺少的 IO HW 有关(并且我有键盘/鼠标,但没有调用它们)。
我应该怎么做才能正确获取系统剪贴板?
感谢您的评论和 Roshana Pitigala 的回答,我理解了我的错误:实际上 Java 应用程序是在 DC 上运行,而不是在用户本地环境中运行。因此,获取用户系统剪贴板将获取 DC 剪贴板(而不是用户)。该解决方案需要位于客户端(在客户环境中运行)。
java ×3
android ×2
spring-boot ×2
c# ×1
c++ ×1
clipboard ×1
events ×1
junit4 ×1
junit5 ×1
mouseevent ×1
oracle ×1
qml ×1
qt ×1
spring-cloud ×1
wpf ×1