小编Nas*_*ikh的帖子

使用Google排球进行SSL固定

我提到我到目前为止所尝试的内容,我开始提出问题:

我的应用程序中没有证书,我只使用SHA256密钥,互联网上的大多数答案都需要应用程序中的物理证书才能将其加载到密钥库中,我没有.

我收到以下错误:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)

1)TrustKit它需要编译SDK 24及以上,但我有23个和许多支持库与SDK 23同步所以我无法更改所有这些,它可能会在某个时候崩溃我的应用程序.

2)CWAC-NetSecurity我在我的代码中实现了这个,没有使用Android N安全设置,我也遵循git页面上给出的指令,但是不能将sslSocketfactory传递给Volley,它有OkHTTP的例子.所以它也给出了上述错误.

我用OKHttp的CertificatePinner尝试了这个,它也不适用于我.同样的错误.我也尝试将hostNameVerifier和sslSocketFactory传递给HttpsUrlConnection但是同样的错误.

JsonObjectRequestSolaire jsonRequest = new JsonObjectRequestSolaire(method, URL, object, headers, responseListener, errorListener);
    RetryPolicy policy = new DefaultRetryPolicy(TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    jsonRequest.setRetryPolicy(policy);
    jsonRequest.setShouldCache(false);

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .certificatePinner(new CertificatePinner.Builder()
                    .add("my_domain", "sha256/shaKey")//example.com
                    .add("my_domain", "sha256/shaKey")//also tried *.example.com
                    .build())
            .build();

    //HttpsURLConnection.setDefaultHostnameVerifier(okHttpClient.hostnameVerifier());
    //HttpsURLConnection.setDefaultSSLSocketFactory(okHttpClient.sslSocketFactory());

    RequestQueue requestQueue = Volley.newRequestQueue(activity.getApplicationContext(), new HurlStack(null, okHttpClient.sslSocketFactory()));
    requestQueue.add(jsonRequest);
Run Code Online (Sandbox Code Playgroud)

通过使用trustKit我们的iOS人员实现,它正在为他工作.

提前致谢.

请在这里分享您的宝贵意见,以便我能理解这个SSL固定概念.

android android-volley okhttp3 certificate-pinning public-key-pinning

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

如何滚动到Horizo​​ntalScrollView的子项中心?

我需要滚动到Horizo​​ntalScrollView的childView(TextView)的中心.我通过使用下面的代码获得了中心孩子,现在我想将箭头调整到该子视图的确切中心.

在这里,我所做的是我拿了一个Horizo​​ntalScrollView,里面有一个LineaerLayout,在LinearLayout里面我有TextViews.

这是我的XML:

 <com.sample.test.ScrollViewCustom
                android:id="@+id/mHorizontalScrollViewMain"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/relativeOne"
                android:background="@drawable/mergethree2"
                android:scrollbars="none" >

                <LinearLayout
                    android:id="@+id/llayoutfirst"
                    android:layout_width="wrap_content"
                    android:layout_height="55dip"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dip"
                        android:background="@drawable/blackline" />

                    <TextView
                        android:id="@+id/mtxtHome"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginBottom="5dip"
                        android:layout_marginLeft="5dip"
                        android:layout_marginRight="5dip"
                        android:layout_marginTop="8dip"
                        android:text="home"
                        android:textColor="@android:color/white"
                        android:textSize="15sp"
                        android:typeface="serif" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dip"
                        android:background="@drawable/blackline" />

                    <TextView
                        android:id="@+id/mtxtSchools"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginBottom="5dip"
                        android:layout_marginLeft="5dip"
                        android:layout_marginRight="5dip"
                        android:layout_marginTop="8dip"
                        android:text="schools"
                        android:textColor="@android:color/white"
                        android:textSize="15sp"
                        android:typeface="serif" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dip"
                        android:background="@drawable/blackline" />

                    <TextView
                        android:id="@+id/mtxtCalendar"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginBottom="5dip"
                        android:layout_marginLeft="5dip"
                        android:layout_marginRight="5dip"
                        android:layout_marginTop="8dip"
                        android:text="calendar"
                        android:textColor="@android:color/white"
                        android:textSize="15sp"
                        android:typeface="serif" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android rect horizontalscrollview

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

如何找到Horizo​​ntalScrollView的滚动值结束

我需要实现以下场景,

这里我有两个horizo​​ntalScrollViews,上面的scrollView是一个主菜单,下面的scrollView是一个子菜单.

当我滚动主菜单时,位于中心箭头下方的菜单将在下方滚动视图中显示其子菜单,而从下方滚动视图中,位于中心箭头下方的子菜单显示该子菜单的屏幕.

这是我的要求:在此输入图像描述

我已经使用Horizo​​ntalScrollViews和ViewFlipper实现了它并且它也可以工作,但只有当我慢慢滚动而不是滚动快速时它才会给出正确的结果.

我已经将onTouch()方法与ACTION_UP事件一起使用,所以当我从屏幕释放手指时,它会在该点给我getScrollX()位置,但是在滚动完成/停止时我需要getScrollX()位置.

这是我的代码: -

  @Override
    public boolean onTouch(View v, MotionEvent event) {
        switch (v.getId()) {

            case R.id.mHorizontalScrollViewMain:
           if (event.getAction() == KeyEvent.ACTION_UP) {
            Log.d("test", " " + hsvUpperTab.getScrollX() + " , "+ mViewFlipper.getChildCount());
            getUpperTabScrolled(hsvUpperTab.getScrollX());
        }
        break;

        case R.id.mHorizontalScrollViewSub:
                if (event.getAction() == KeyEvent.ACTION_UP) {
            Log.d("test1", " " + hsvLowerTab.getScrollX());
            getLowerTabScrolled(hsvLowerTab.getScrollX());

            }

        default:
            break;

        }

        return false;
    }
Run Code Online (Sandbox Code Playgroud)

android scrollbar horizontalscrollview

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

将图像用作GoogleMap

我从json得到纬度和经度,我想在地图上显示它们.我使用googleMap和Overlays等正常方式完成了它.但实际上我希望它像下面的图像.

在此输入图像描述

我已经搜索并得到一些提示,比如在webView中显示地图并使用Javascript.但是没有找到任何教程或示例代码.

它是静态图像,不会放大或缩小.我想把位置坐标放在图像上.

所以我的问题是,是否有可能将图像作为gooleMap?

提前致谢.

在此输入图像描述

android google-maps android-mapview

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

应用程序未出现在Android Market for Tablet中

我在Android市场上传了一个Android应用程序.

当我从手机上搜索它时,它会出现在搜索中,但是当我从我的平板电脑中搜索它时却没有.

有谁能解释为什么?

android google-play

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