我刚刚在Android SDK Manager中将Google Play服务更新到最新版本 - 23.接下来,我将项目中的依赖项更新为:
com.google.android.gms:play-services-gcm:8.3.0
但我得到了:
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-gcm:8.3.0, but version 8.1.0 is needed
:app:processDebugGoogleServices FAILED
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
Run Code Online (Sandbox Code Playgroud)
怎么了?你有这个问题吗?
android google-play-services android-studio android-gradle-plugin
我有一个10页的ViewPager.当我开始onCreateView()调用我的片段的最后一个(第10个)页面方法时.当我滑到第9页时onCreateView()也被调用.但是当我回到第10页时onCreateView()没有被调用.怎么了?
android android-fragments android-viewpager android-pageradapter
我的操作栏中有一个菜单,其中包含两个项目。打开搜索视图后仍然显示“一支笔”。我怎样才能隐藏它?
菜单.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/search"
android:title="@string/search"
android:icon="@drawable/ic_search"
app:actionViewClass="android.widget.SearchView"
app:showAsAction="ifRoom|withText" />
<item
android:id="@+id/edit"
android:icon="@drawable/ic_edit"
android:title="@string/edit"
app:showAsAction="ifRoom|withText" />
</menu>
Run Code Online (Sandbox Code Playgroud)
我也试过:
app:showAsAction="collapseActionView|ifRoom"
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,我有:
我想得到与第二张图片相同的内容。但是编辑图标应该隐藏或最终显示为一个整体。
编辑
基于@Ahmad Alsanie 的回答,我是这样写的:
SearchView view = (SearchView) menu.findItem(R.id.search).getActionView();
view.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
menu.findItem(R.id.edit).setVisible(false);
});
Run Code Online (Sandbox Code Playgroud)
它有效,但如何在关闭搜索视图后恢复编辑图标?我尝试过setOnCloseListener但没有成功。
我想获得铃声名称.我用这个代码
Ringtone ringtone = RingtoneManager.getRingtone(preference.getContext(), Uri.parse(stringValue));
String name = ringtone.getTitle(preference.getContext());
Run Code Online (Sandbox Code Playgroud)
我得到的号码(例如 - 17090)不是铃声名称.怎么了?
根据本文,我尝试使用Cookie来实现针对我的android客户端应用程序的身份验证-http: //automateddeveloper.blogspot.co.uk/2014/03/securing-your-mobile-api-spring-security.html
SecurityConfig:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final static String TOKEN_STRING = "my_token";
private final static String COOKIE_STRING = "my_cookie";
@Autowired
private UserDetailsService userSvc;
@Autowired
private MyTokenBasedRememberMeService tokenSvc;
@Autowired
private RememberMeAuthenticationProvider rememberMeProvider;
@Autowired
private MyAuthSuccessHandler authSuccess;
@Autowired
private MyAuthFailureHandler authFailure;
@Autowired
private MyLogoutSuccessHandler logoutSuccess;
@Autowired
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userSvc)
.passwordEncoder(passwordEncoder());
auth.authenticationProvider(rememberMeProvider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/register").permitAll()
.anyRequest().authenticated().and()
.formLogin()
.loginPage("/")
.loginProcessingUrl("/loginendpoint")
.successHandler(authSuccess)
.failureHandler(authFailure).and()
.logout() …Run Code Online (Sandbox Code Playgroud) 将struct数组传递给gpu内核时遇到问题.我基于这个主题 - cudaMemcpy分段错误,我写了这样的:
#include <stdio.h>
#include <stdlib.h>
struct Test {
char *array;
};
__global__ void kernel(Test *dev_test) {
for(int i=0; i < 5; i++) {
printf("Kernel[0][i]: %c \n", dev_test[0].array[i]);
}
}
int main(void) {
int n = 4, size = 5;
Test *dev_test, *test;
test = (Test*)malloc(sizeof(Test)*n);
for(int i = 0; i < n; i++)
test[i].array = (char*)malloc(size * sizeof(char));
for(int i=0; i < n; i++) {
char temp[] = { 'a', 'b', 'c', 'd' , 'e' };
memcpy(test[i].array, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用POST请求插入数据,但出现403错误。使用GET时,基本身份验证有效。为了进行测试,我使用了Fiddler。
有什么问题?
安全配置:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/**").hasRole("USER").and()
.httpBasic();
}
@Override
protected void configure(AuthenticationManagerBuilder auth)
throws Exception {
auth
.inMemoryAuthentication()
.withUser("user")
.password("password")
.roles("USER");
}
}
Run Code Online (Sandbox Code Playgroud)
请求-POST:
User-Agent: Fiddler
Host: localhost:8080
Content-Length: 200
Content-Type: application/json
Authorization: Basic dXNlcjpwYXNzd29yZA==
Run Code Online (Sandbox Code Playgroud)
要求正文:
{"name" : "name1",
"description" : "desc1"}
Run Code Online (Sandbox Code Playgroud) java spring spring-security basic-authentication spring-boot
为gpu初始化大量整数的最佳方法(有效)是什么?我需要为前两个元素分配1,为其他元素分配0(对于Eratosthenes的Sieve).
注意:数组大小是动态的(n作为参数传递).
我目前的版本:
int array = (int*) malloc(array_size);
array[0] = 1;
array[1] = 1;
for (int i = 2; i < n; i++) {
array[i] = 0;
}
HANDLE_ERROR(cudaMemcpy(dev_array, array, array_size, cudaMemcpyHostToDevice));
kernel<<<10, 10>>>(dev_array);
Run Code Online (Sandbox Code Playgroud)
我要感谢一个例子.
是否可以将Cassandra(使用CQL)存储在具有相同列数但具有一个不同列的一个列族中的两行中?像这样的东西:
// column family
'users' : {
// row 1
'john' : {
name: 'John',
lastname: 'Smith',
email: 'john@gmail.com'
}
// row 2
'jack' : {
name: 'Jack',
lastname: 'Sparrow',
age: 33
}
}
Run Code Online (Sandbox Code Playgroud)
我目前的CQL代码:
CREATE KEYSPACE people WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
USE people;
CREATE COLUMNFAMILY users (
username varchar PRIMARY KEY,
name varchar,
lastname varchar,
email varchar
);
INSERT INTO users (username, name, lastname, email) VALUES ('john', 'John', 'Smith', 'john@gmail.com');
ALTER TABLE …Run Code Online (Sandbox Code Playgroud)