小编Jav*_*nes的帖子

build.gradle中的相对路径因Windows和OS X而异

我的项目有一个包含密钥库文件的文件夹(file.keystore).这是结构:

+---.gradle
|   \---2.2
|       \---taskArtifacts
+---.idea
|   +---copyright
|   \---libraries
+---app
|   +---build
|   |   +---generated
|   +---libs
|   \---src
|       +---androidTest
|       \---main
+---build
|   \---intermediates
|       \---dex-cache
+---gradle
|   \---wrapper
\---keystore
Run Code Online (Sandbox Code Playgroud)

要在build.gradle中使用它,我使用:

signingConfigs {
    project {
        keyAlias 'project'
        keyPassword 'blabla'
        storeFile file('keystore\\file.keystore')
        storePassword 'blabla'
    }
Run Code Online (Sandbox Code Playgroud)

在Windows中,一切都是正确的,因为它搜索:

/project/keystore/file.keystore

但在OS X中,它正在搜索:

/project/app/keystore/file.keystore

我应该如何在build.gradle中编码?

android android-gradle-plugin

12
推荐指数
2
解决办法
5987
查看次数

新 Apple 登录不断抛出错误 HTTP 400 Invalid_grant

根据Apple doc验证针对Apple的身份验证代码,我们需要使用以下参数POST到http://appleid.apple.com/auth/token

#!java

token = generateJWT(keyId, teamId, clientId, certificatePath);

HttpResponse<String> response = Unirest.post(authUrl)
     .header("Content-Type", "application/x-www-form-urlencoded")
     .field("client_id", clientId)
     .field("client_secret", token)
     .field("grant_type", "authorization_code")
     .field("code", authorizationCode)
     .asString();

Run Code Online (Sandbox Code Playgroud)

在哪里:

  • authorization_code : 是应用客户端提供的授权码。

  • clientId:由 Apple 提供

  • 令牌:是客户端机密。使用以下代码生成 JWT:

#!java

private static String generateJWT(String keyId, String teamId, String clientId, String certificatePath) throws Exception {
        if (pKey == null) {
            pKey = getPrivateKey(certificatePath);
        }

        return Jwts.builder()
                .setHeaderParam(JwsHeader.KEY_ID, keyId)
                .setIssuer(teamId)
                .setAudience("https://appleid.apple.com")
                .setSubject(clientId)
                .setExpiration(new Date(System.currentTimeMillis() + (1000 * 60 * 5)))
                .setIssuedAt(new Date(System.currentTimeMillis()))
                .signWith(pKey, …
Run Code Online (Sandbox Code Playgroud)

java authentication spring ios

8
推荐指数
2
解决办法
3690
查看次数

更改 Android 谷歌地图中的 clustermanager 项目图标

我的 Android 应用程序中有一个谷歌地图。它充满了标记,它聚集了标记......简而言之,这是一张完全可用的地图。

我想做的事情很简单。当用户点击 clusterItem 时,我想将图标更改为选定的图标。(简单地说,相同的标记但颜色不同)。

我如何在屏幕上使用大量标记,每次单击标记时都不可能清理地图并添加标记。

所以:

mClusterManager.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<MyItem>() {
    @Override
    public boolean onClusterItemClick(MyItem myItem) {
        if (oldItemSelected != null) {
            mClusterManager.removeItem(oldItemSelected);
            oldItemSelected.setItemAsNotSelected();
            mClusterManager.addItem(oldItemSelected);
        }

        mClusterManager.removeItem(myItem);
        myItem.setItemAsSelected();
        mClusterManager.addItem(myItem);
        mClusterManager.cluster();

        oldItemSelected = myItem;
        return true;
    }
});
Run Code Online (Sandbox Code Playgroud)

这个想法是从地图中删除单击的项目,将其设置为“选定”,添加新项目并使用 .cluster 方法刷新地图。

会发生什么:该项目没有改变,有时该项目是“重复的”并且所选项目位于“正常”项目的后面。

这就是我设置集群管理器的方式:

mClusterManager = new ClusterManager<MyItem>(this, map);
mClusterManager.setRenderer(new MyItemRenderer());
mClusterManager.setAlgorithm(new GridBasedAlgorithm<MyItem>());
map.setOnMarkerClickListener(mClusterManager);
Run Code Online (Sandbox Code Playgroud)

这是项目渲染器:

private class MyItemRenderer extends DefaultClusterRenderer<MyItem> {
    public MyItemRenderer() {
        super(getApplicationContext(), map, mClusterManager);
    }

    @Override
    protected void onBeforeClusterItemRendered(MyItem myItem, MarkerOptions markerOptions) {
        markerOptions.title(myItem.getName());
        markerOptions.snippet(myItem.getAddress());
        markerOptions.icon(BitmapDescriptorFactory.fromResource(myItem.getIcon()));
    }

    @Override
    protected …
Run Code Online (Sandbox Code Playgroud)

android google-maps android-maps-utils

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

AndroidTestCompile依赖项在导入中无法识别

实际上,我的项目有单元测试.所有这些都配置在/src/test/java/最近我需要添加仪器测试/src/androidTest/java.为此,我添加了espresso依赖项build.gradle.

dependencies {
    compile files('libs/pixlui-1-0-5.jar')
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
        transitive = true
    }
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.google.android.gms:play-services-maps:7.3.0'
    compile 'com.google.android.gms:play-services-location:7.3.0'
    compile 'com.google.android.gms:play-services-gcm:7.3.0'

    compile 'com.loopj.android:android-async-http:1.4.5'
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:support-v4:20.+'
    compile 'ch.acra:acra:4.5.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
    compile 'com.squareup.picasso:picasso:2.3.4'
    provided 'com.squareup.dagger:dagger-compiler:1.2.+'
    compile 'com.squareup.dagger:dagger:1.2.+'
    compile 'com.google.guava:guava:15.0'
    compile 'com.facebook.android:facebook-android-sdk:3.23.0'
    compile …
Run Code Online (Sandbox Code Playgroud)

java android android-espresso

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

Chrome自定义标签会在工具栏外显示操作按钮

我想在ChromeCustomTabs的工具栏中添加一个操作按钮,因此我按照本教程进行操作

该按钮已添加,但它不会显示在工具栏中,而是显示在活动的底部:

ChromeCustomTab

这是我用来创建Chrome自定义标签的代码:

private static void openUrlInChromeCustomTab(String webUrl, Activity activity, Item item) {
    if (!(webUrl.startsWith("http:") || webUrl.startsWith("https:"))) {
        webUrl = "http://" + webUrl;
    }

    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();

    Bitmap largeIcon = BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_share);

    Product product = (Product) item;

    PendingIntent pendingIntent;
    Intent intent = new Intent();
    intent.setClass(activity, SharingDummyActivity.class);

    Bundle bundle = new Bundle();
    bundle.putSerializable(SharingDummyActivity.PRODUCT_CRITERIA, product);
    intent.putExtras(bundle);

    pendingIntent =  PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);


    //builder.setActionButton(largeIcon, activity.getResources().getString(R.string.custom_tag_share_description), pendingIntent ,true);
    builder.setActionButton(largeIcon, activity.getResources().getString(R.string.custom_tag_share_description), pendingIntent);

    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.launchUrl(activity, Uri.parse(webUrl));

}
Run Code Online (Sandbox Code Playgroud)

如何让工具栏内的动作按钮靠近三个点?我错过了什么吗?

android chrome-custom-tabs

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