小编Bak*_*123的帖子

找到com.google.android.gms:play-services-gcm:8.3.0,但需要版本8.1.0

我刚刚在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

40
推荐指数
2
解决办法
3万
查看次数

ViewPager - 并不总是调用onCreateView

我有一个10页的ViewPager.当我开始onCreateView()调用我的片段的最后一个(第10个)页面方法时.当我滑到第9页时onCreateView()也被调用.但是当我回到第10页时onCreateView()没有被调用.怎么了?

android android-fragments android-viewpager android-pageradapter

15
推荐指数
2
解决办法
9886
查看次数

操作栏 - 隐藏除搜索字段之外的所有菜单项

我的操作栏中有一个菜单,其中包含两个项目。打开搜索视图后仍然显示“一支笔”。我怎样才能隐藏它?

菜单.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但没有成功。

android menuitem android-actionbar

6
推荐指数
2
解决办法
3750
查看次数

数字而不是铃声名称

我想获得铃声名称.我用这个代码

Ringtone ringtone = RingtoneManager.getRingtone(preference.getContext(), Uri.parse(stringValue));
String name = ringtone.getTitle(preference.getContext());
Run Code Online (Sandbox Code Playgroud)

我得到的号码(例如 - 17090)不是铃声名称.怎么了?

android android-preferences android-contentprovider

5
推荐指数
1
解决办法
1079
查看次数

Spring-使用cookie的RESTful身份验证

根据本文,我尝试使用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)

cookies spring spring-security spring-boot

4
推荐指数
1
解决办法
1万
查看次数

GPU上的内存分配用于动态结构数组

将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)

c struct cuda dynamic-memory-allocation

2
推荐指数
1
解决办法
2048
查看次数

Spring Security-基本身份验证

我正在尝试使用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

2
推荐指数
1
解决办法
1370
查看次数

Cuda - 大阵列初始化

为gpu初始化大量整数的最佳方法(有效)是什么?我需要为前两个元素分配1,为其他元素分配0(对于Eratosthenes的Sieve).

  1. cudaMemcpy
  2. cudaMemset +在内核中设置2个第一个元素的值
  3. 初始化直接在内核中
  4. 别的

注意:数组大小是动态的(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)

我要感谢一个例子.

c cuda

2
推荐指数
1
解决办法
2171
查看次数

CQL - 具有不同列的行

是否可以将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)

cql cassandra nosql datastax cassandra-2.0

1
推荐指数
1
解决办法
981
查看次数