小编Two*_*cks的帖子

如何使用Google API客户端在Google Map Android中显示我当前的位置

我想在地图上显示我的位置并放大它.我想使用GoolgeAPIClient.地图渲染和指针创建但位置错误.我觉得即使在调用GoogleAPIClient的onConnected方法之前,也会先执行onMapReady.请帮助这是我的代码.

import android.location.Location;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MarkerOptions;


public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
    protected static final String TAG = "MainActivity";

    /**
     * Provides the entry point to Google Play services.
     */
    protected GoogleApiClient mGoogleApiClient;

    /**
     * Represents a geographical location.
     */
    protected Location mLastLocation;

    protected String mLatitudeLabel;
    protected …
Run Code Online (Sandbox Code Playgroud)

android google-maps-android-api-2

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

Map Api Key和Google Places Api是一样的吗?

我希望我不会得到一个投票,英语不是我的第一语言,这就是我被api文件弄糊涂的原因.如果我需要为"Google Maps Android API"和"Google Places API for Android"生成不同的api密钥,我感到很困惑

我问,因为我成功地使用谷歌地图android api从我的Android应用程序渲染地图但是当我尝试使用官方谷歌android的代码放置api示例(PLACE PICKER)它失败而没有抛出任何错误.它会正确呈现活动,但是当我单击"查找位置"按钮时,它只会将我返回到之前的活动而没有错误.我猜这可能是一个api密钥问题,这就是为什么我问我是否需要两个不同的api密钥呢?

android google-maps google-places-api google-play-services

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

SpringBoot,如何在不使用 ldif 的情况下使用 LDAP 进行身份验证?

我在这里尝试 SpringBoot 中的 LDAP 身份验证示例

它使用的是 ldif 方法,我认为这不适用于我的要求,因为我们的 ldap 管理员不会告诉我在哪里可以找到我需要的 ldif。在 springboot 之前,我曾经使用我自己的 ldap 实现而不使用 ldif。有没有办法验证不使用 ldif 只是 SECURITY_AUTHENTICATION.simple ?下面是我如何在基本的 Java no spring 中执行 ldap 安全性。如何在不使用 ldif 只是基本用户名密码的情况下在 spring 中执行此操作。

boolean isLdapRegistred(String username, String password) {
    boolean result = false;
    try {

        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL, "ldap://10.x.x.x:389");           
        env.put(Context.SECURITY_AUTHENTICATION, "simple");         
        env.put(Context.SECURITY_PRINCIPAL, "OUR-DOMAIN\\" + username);
        env.put(Context.SECURITY_CREDENTIALS, password);

        // Create the initial context
        DirContext ctx = new InitialDirContext(env);
        result = ctx != null;
        if (ctx …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot

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

在简单的PHP程序中找不到类'NumberFormatter'错误

我有一个简单的PHP程序,但我遇到这个错误:

未找到"NumberFormatter"类

我已经在Stackoverflow中研究过类似的问题,但老实说没有人给出具体的解决方案.其他人建议升级PHP的版本,其他人则取消对php.ini文件中特定行的注释,但这些都不适用于我.

下面是我的代码:我甚至使用了https://bugs.php.net建议的解决方案,但它仍然不起作用.

<!DOCTYPE html>
<html>
<body>

<?php
function writeMsg(){

$f = new \NumberFormatter("en", \NumberFormatter::SPELLOUT);    

echo $f->format(1432);
}
writeMsg();
?>  

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

php numberformatter

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

无法访问IIS上的本地Bonobo Git Server主页

我按照所有说明安装了Windows版Bonobo Git服务器,但并未重定向到主页localhost / Bonobo.Git.Server,而是显示了应用程序的内容,请参见下图。我做错了什么以及如何解决?

在此处输入图片说明

git iis bonobo

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

如何在线性布局上并排布局元素并应用适当的间距和对齐方式

我在使用元素并排在一起的线性布局时遇到问题。通过将元素放在 TableView 中,我可以让它们在线性布局中并排排列,但我无法对它们应用正确的对齐方式。例如 TextView1 必须左对齐,它的伙伴 TextView2 右对齐即使我使用按钮也不会右对齐

android:layout_alignParentRight="true"
Run Code Online (Sandbox Code Playgroud)

我正在尝试创建一个收据活动,其中标题“SubTotal”、“tax”、“Total”左对齐,它们的值右对齐下面是我的 xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:paddingTop="20dp"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    android:paddingBottom="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/app_bar_main"
    tools:context=".MainActivity"
    android:elevation=".5dp"
    android:focusable="true"
    android:layout_centerHorizontal="true">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:orientation="vertical"
    android:gravity="bottom">

    <TextView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="SAN AGUSTIN MUSEUM"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textViewTicketName"/>
    <TextView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="20dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="(Comes with Audio Guide)"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textViewTicketDesc"/>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/border"
        android:orientation="vertical"
        android:gravity="bottom">



        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

        <TextView
            android:id="@+id/TblText1"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:text="Subtotal:"/>

        <TextView
            android:id="@+id/TblText11"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:text="$5.00"
            android:layout_alignParentRight="true"/> …
Run Code Online (Sandbox Code Playgroud)

android android-layout

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

如何使用 Android Media Player 搜索栏控制音频?

我可以使用 android 媒体播放器来播放音频文件。我可以显示进度条和附加的 2 个按钮来暂停和播放音轨。我的问题是我无法使用进度条控制轨道。我想播放音轨以根据我将进度条拖动到的位置进行更新。

下面是我的代码

public class MyMediaPlayerView extends AppCompatActivity implements View.OnClickListener {

            /**
             * var for controller
             * restore timestamp today 12:11
             */
             SeekBar seek_bar;
             Button play_button, pause_button;
             MediaPlayer player;
             TextView text_shown;
             Handler seekHandler = new Handler();


            @Override
            protected void onCreate(Bundle savedInstanceState) {
                 super.onCreate(savedInstanceState);
                 setContentView(R.layout.activity_launch_webview);
                 getSupportActionBar().setDisplayHomeAsUpEnabled(true);

                 getInit();
                 seekUpdation();
             }

             Runnable run = new Runnable() {
                @Override public void run() {
                     seekUpdation();
                }
             };

             public void seekUpdation() {
                 seek_bar.setProgress(player.getCurrentPosition());
                 seekHandler.postDelayed(run, 1000);

                 onProgressChanged(seek_bar, seek_bar.getProgress());
             }

             @Override 
             public void onClick(View view) …
Run Code Online (Sandbox Code Playgroud)

android android-mediaplayer

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

为什么Android location.distance要以百万为单位返回值?

在我的Android应用程序中,我试图计算两个位置之间的距离,但获得的值却是数以千万计的1100万以上。两点/位置之间的实际距离仅为1.1km-1.3Km。为什么会这样呢?即使.distanceTo方法返回的值以米为单位,1100万米仍然是一个很大的值。

这是我的代码:

        Location locationA = new Location("LocationA");
        locationA.setLatitude(lat);
        locationA.setLongitude(lang);

        Location locationB = new Location("LocationB");
        locationB.setLatitude(14.575224);
        locationB.setLongitude(121.042475);

        float distance = locationA.distanceTo(locationB);
        BigDecimal _bdDistance;
        _bdDistance = round(distance,2);
        String _strDistance = _bdDistance.toString();      

Toast.makeText(this, "distance between two locations = "+_strDistance, Toast.LENGTH_SHORT).show();

  public static BigDecimal round(float d, int decimalPlace) {
        BigDecimal bd = new BigDecimal(Float.toString(d));
        bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
        return bd;
    }
Run Code Online (Sandbox Code Playgroud)

android android-maps android-maps-v2

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