小编kal*_*ani的帖子

如何在Android中的MAPBOX中获取当前位置

当我在应用程序中使用MAPBOX时,我不知道如何获取当前经纬度和经度。我使用这种方式获取当前位置,但其显示空对象引用,请帮助我解决问题

     mapView = (MapView)view. findViewById(R.id.mapView);
    mapView.setStyleUrl(Style.MAPBOX_STREETS);
    mapView.onCreate(savedInstanceState);

    //Add a mapBoxMap
    mapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(MapboxMap mapboxMap) {
            mapboxMap.setMyLocationEnabled(true);
            // Set the origin waypoint to the devices location
            Position origin = Position.fromCoordinates(mapboxMap.getMyLocation().getLongitude(), mapboxMap.getMyLocation().getLatitude());

            Log.i("RR","mapboxMap.getMyLocation();"+origin);
           // Log.i("RR","mapboxMap.getMyLocation();"+mapboxMap.getMyLocation().getLongitude());
            mapboxMap.getUiSettings().setZoomControlsEnabled(true);
            mapboxMap.getUiSettings().setZoomGesturesEnabled(true);
            mapboxMap.getUiSettings().setScrollGesturesEnabled(true);
            mapboxMap.getUiSettings().setAllGesturesEnabled(true);


        }

    });
Run Code Online (Sandbox Code Playgroud)

android mapbox mapbox-android

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

原因:java.lang.ClassNotFoundException:在Android中找不到类“java.awt.Desktop”

我正在 android 中运行 java 代码,以便在 android 中使用 oauth 2.0 制作凭证,当我运行此代码时,我遇到问题:

这是我的问题:

原因:java.lang.ClassNotFoundException:在路径上找不到类“java.awt.Desktop”:DexPathList[[zip 文件“/data/app/com.retrofitdemo-1/base.apk”],nativeLibraryDirectories=[ /供应商/lib64,/系统/lib64]]

这是我的代码:

 private static final GoogleClientSecrets googleSecrets = new GoogleClientSecrets();
 googleSecrets.setInstalled(
            new GoogleClientSecrets.Details()
                    .setClientId("542678605378-hlspiumlr34nq04cmjtkft17i6k3hvr0.apps.googleusercontent.com")
                    .setClientSecret("{client_secretid}")
    );
    // Build flow and trigger user authorization request.
    GoogleAuthorizationCodeFlow flow =
            new GoogleAuthorizationCodeFlow.Builder(
                    AndroidHttp.newCompatibleTransport(), JacksonFactory.getDefaultInstance(), googleSecrets, Arrays.asList(SCOPES))
 .setAccessType("offline")
                    .build();
    Credential credential1 = new AuthorizationCodeInstalledApp(
            flow, new LocalServerReceiver()).authorize("user");
    Log.i("AA","credential1--"+credential1);

    new MakeRequestTask(credential).execute();
Run Code Online (Sandbox Code Playgroud)

如何在android中导入awt包?

android

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

如何在android中的textview中对齐文本并正确对齐

我有一个TextViewin xml,但我给出了TextViewjava 中的值。同时显示其不正确的对齐方式。请您给出解决方案。

Xml我给出的值意味着它显示正确,但在java中我给出的值它没有以正确的方式显示。我想证明文本合理

    <TextView 
    android:text="" android:id="@+id/result"
    android:layout_marginTop="13dp"
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="left|center|right" 
    android:gravity="left|center|right" 
    android:textStyle="bold" 
    android:textAlignment="center" 
    android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp"
    android:textSize="15dp" />
Run Code Online (Sandbox Code Playgroud)

android alignment textview

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

标签 统计

android ×3

alignment ×1

mapbox ×1

mapbox-android ×1

textview ×1