我想知道是否有可能有一个以startService启动的服务,然后能够绑定到该服务并执行一些远程过程调用?根据这个:http://developer.android.com/guide/topics/fundamentals.html#servlife
这两种服务有不同的生命周期,所以不可能,有人知道吗?
我已经使用Android内部存储为我的应用程序保存文件(使用openFileOutput)但我想删除该文件,是否可能以及如何?
我想获得用户联系人,然后附加某种正则表达式并将它们附加到列表视图.我目前能够获得所有联系人
getContentResolver().query(People.CONTENT_URI, null, null, null, null);
然后将它们传递给扩展的自定义类SimpleCursorAdapter.
所以我想知道如何只获得与正则表达式匹配的联系人而不是所有用户联系人.
我的项目包括两个不同的部分,一个JSF管理面板和一个RESTfull服务.我正在尝试设置spring security以使用不同的身份验证方法,具体取决于用户导航的URL.
要求是
单独的配置单独工作,问题是当我尝试在一个配置中组合它们时,在这种情况下,似乎REST提供程序阻碍并验证每个请求,即使请求转到管理URL(这从春季安全订购中记录).
我的示例配置如下所示:
对于表单登录(JSF)
@Override
@Order(1)
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/resources/**").permitAll()
.antMatchers("/templates/**").permitAll()
.antMatchers("/401.html").permitAll()
.antMatchers("/404.html").permitAll()
.antMatchers("/500.html").permitAll()
.antMatchers("/api/**").permitAll()
.antMatchers("/ui/admin.xhtml").hasAnyAuthority("admin", "ADMIN")
.antMatchers("/thymeleaf").hasAnyAuthority("admin", "ADMIN")
//.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/ui/index.xhtml")
.failureUrl("/login?error=1")
.permitAll()
.and()
.logout()
.permitAll()
.and()
.rememberMe()
.and().exceptionHandling().accessDeniedPage("/error/403");
Run Code Online (Sandbox Code Playgroud)OAuth2安全配置(REST)
@EnableResourceServer
@Order(2)
public class RestSecurityConfig extends WebSecurityConfigurerAdapter {
@Inject
private UserRepository userRepository;
@Inject
private PasswordEncoder passwordEncoder;
@Bean
ApplicationListener<AbstractAuthorizationEvent> loggerBean() {
return new AuthenticationLoggerListener();
}
@Bean
AccessDeniedHandler accessDeniedHandler() {
return new AccessDeniedExceptionHandler();
}
@Bean
AuthenticationEntryPoint entryPointBean() { …Run Code Online (Sandbox Code Playgroud)我想提示用户使用对话框在我的android应用程序中输入.这是我发现的:
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Title");
alert.setMessage("Message");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText();
// Do something with value!
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show();
Run Code Online (Sandbox Code Playgroud)
但这给了我:
android.view.WindowManager $ BadTokenException:无法添加窗口 - 令牌null不适用于应用程序
我的代码有什么问题似乎在对话框上传递了一个null参数,但我无法找出问题所在.
您好我想自定义屏幕上绘制默认EditText的方式,我有这个代码
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape android:shape="rectangle">
<solid
android:color="#00ff00" />
<stroke
android:width="5dp"
android:color="#ff0000"
android:dashWidth="3dp"
android:dashGap="2dp" />
</shape>
</item>
<item android:state_focused="true" >
<shape>
<gradient
android:endColor="#8dc73f"
android:centerColor="#d4d4d4"
android:startColor="#d4d4d4"
android:centerX="0.5"
android:centerY="0.5"
android:angle="270" />
<stroke
android:width="1dp"
color="#8dc73f" />
<corners
android:radius="6dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:endColor="#d4d4d4"
android:centerColor="#d4d4d4"
android:startColor="#d4d4d4"
android:angle="270" />
<stroke
android:width="1dp"
color="#00ff00" />
<corners
android:radius="7dp" />
</shape>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
哪个工作正常但问题是在聚焦状态下我想应用EditText的效果并且注意里面,就像应用默认的android效果一样,这是可能的,因为我没有找到解决方案,上面的代码只在EditText中应用效果.
可以在Android中播放互联网广播流吗?而且由于大多数互联网收音机都使用彩信来传输他们的内容,这可能是使用Android吗?
我正在试图勉强地将hibernate OneToOne关系工作.
我的设置是使用hibernate和Gradle的spring-data-jpa.
即使这是一个记录良好的问题/功能,并且有很多好的读取,我已经意识到他们中的大多数正在处理maven.
幸运的是,有一个Gradle插件可以用于这个特殊的原因,即使文档不是最好的,我发现这个帖子也处理相同的问题,它似乎是一个非常简单的解决方案.
在我实现了Gradle脚本中所需的更改之后,似乎hibernate仍然急切地加载了OneToOne关系,所以我尝试执行
./gradlew build
并注意到打印了以下消息:
跳过Hibernate字节码增强,因为没有启用任何功能
根据插件的源代码,当未启用增强功能时会显示此消息,而不是我正在使用的情况:
hibernate {
enhance {
enableLazyInitialization= true
enableDirtyTracking = true
enableAssociationManagement = true
enableExtendedEnhancement = true
}}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是有人让这个工作正常吗?如果是的话,请您指点一些教程/指南以实现它吗?我在集成测试中使用拦截器来验证hibernate正在使用的查询数以及监视sql日志.
我的gradle文件看起来像:
buildscript {
repositories { mavenCentral() }
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:+'
}
dependencies {
classpath "org.hibernate:hibernate-gradle-plugin:5.2.15.Final"
}
}
plugins {
id "io.spring.dependency-management" version "1.0.3.RELEASE"
}
ext { springBootVersion = '1.5.4.RELEASE' }
ext['flyway.version'] = '4.0.3'
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply …Run Code Online (Sandbox Code Playgroud) hibernate gradle spring-data-jpa spring-boot byte-code-enhancement
我想显示手机的照片库,当用户选择图像然后通知我的应用程序选择的图像,这样我就可以获得图像信息.
是可能的,怎么样?
我正在尝试使用mongodb全文搜索来显示用户正在键入的建议.我已经完成了创建文本索引所需的所有必要步骤,并在数据库上启用了全文搜索功能,除了结果的精度外,一切正常.
我正在使用正则表达式实现相同的逻辑,例如当用户键入"蓝色"时,有一个建议包含'bluetooth'类似于'blue*'的东西,但是使用mongos全文搜索我只在我输入时得到一个结果'bluetoot'.
我已经尝试过使用"字符完全匹配',例如'\'blue \"'以及我能想到的所有其他可以想象的组合但是徒劳无功.
所以我的问题是,是否有办法在mongo中实现这一点?如果mongo支持regexp中使用的*字符之类的东西,或者使用过的算法尝试对单词进行精确匹配?
问候,Maximos