小编Jua*_*ini的帖子

RESOLUTION_REQUIRED 即使用户的位置处于开启状态。是否可以?

SettingsClient在一个应用上使用谷歌。它工作正常,但有些用户无法使用 GPS,即使他们打开了定位并且他们已经授予了定位权限。据我了解,如果在其上Settings Client返回RESOLUTION_REQUIREDFailureListener,那是因为用户已禁用位置。

真的吗?或者是否有任何其他原因返回RESOLUTION_REQUIRED

RESOLUTION_REQUIRED返回时,状态栏上没有显示 GPS 图标,但它应该在那里!

这是我的代码:

    SettingsClient mSettingsClient =
            LocationServices.getSettingsClient(context);

    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(UPDATE_INTERVAL_MS);
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL_MS);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationSettingsRequest.Builder builder = new 
    LocationSettingsRequest.Builder();
    builder.addLocationRequest(mLocationRequest);
    mLocationSettingsRequest = builder.build();

    mSettingsClient.checkLocationSettings(mLocationSettingsRequest)
            .addOnSuccessListener(new OnSuccessListener<LocationSettingsResponse>() {
                @Override
                public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
                    connected = true;
                    // Fused Location code...
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    connected = false;
                    gpsFailureMessage = e.getMessage();
                }
            });
Run Code Online (Sandbox Code Playgroud)

android location

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

Firebase云功能错误代码和错误消息在Android上始终是内部的

我正在为我的应用开发功能,一个用户可以使用云功能向另一个用户发送通知。我的函数和通知可以按预期工作,但是我无法以正确的方式处理错误,因为我的Android代码中始终会出现“ INTERNAL”错误。

这是我的Android代码:

public static Task<String> callFirebaseFunction(HashMap<String, Object> data, String funcion){

    FirebaseFunctions mFunctions = FirebaseFunctions.getInstance();

    return mFunctions
        .getHttpsCallable(funcion)
        .call(data)
        .continueWith(new Continuation<HttpsCallableResult, String>() {
            @Override
            public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
                return (String) task.getResult().getData();
            }
        });
}
Run Code Online (Sandbox Code Playgroud)

这是我打电话给FirebaseFunction的地方

Utilities.callFirebaseFunction(dataNoty, nombreFuncion)
    .addOnCompleteListener(new OnCompleteListener<String>() {
        @Override
        public void onComplete(@NonNull Task<String> task) {
            if ( !task.isSuccessful() ){
                Exception e = task.getException();
                if (e instanceof FirebaseFunctionsException) {
                    FirebaseFunctionsException ffe = (FirebaseFunctionsException) e;
                    FirebaseFunctionsException.Code code = ffe.getCode(); // It's always INTERNAL
                    Object details …
Run Code Online (Sandbox Code Playgroud)

java android node.js firebase google-cloud-functions

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

如何使用 Jetpack 的导航在片段中使用工具栏但不在活动中使用

我已经开始使用 Android Jetpack 的导航库。到目前为止,我觉得它很容易使用。我面临的问题是工具栏。

我想要实现的是:

  1. 用户打开应用程序并显示登录页面。这是导航的开始,不应显示工具栏。
  2. 如果用户第一次登录,将显示重置密码的片段(由管理员自动生成),以便用户更改密码。在这里,我想显示一个带有后退箭头的白色工具栏(没有文字)
  3. 如果用户之前登录过,我们会显示一个加载屏幕(也没有工具栏)

我尝试了很多事情,但没有成功。前两次尝试使用具有NoActionBar样式的活动。

重置密码片段中的工具栏

  • 带有工具栏的自定义 Appbar。它正在显示,但没有显示后退箭头。我尝试在我的工具栏中添加一个 Imageview,我也尝试从 java 设置图标,但这些都不起作用。
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    tools:context=".ResetPasswordFragment">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBar_resetPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:liftOnScroll="true"
        >

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar_resetPassword"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/white"
            />

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:id="@+id/scrollView_resetPassword"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <!-- Linear layout -->

    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

活动中的工具栏

这个尝试奏效了。它在我的活动中添加了一个工具栏,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorAccent"
    android:orientation="vertical"
    tools:context=".LoginActivity">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="?attr/actionBarSize"
        android:layout_width="match_parent"
        android:background="@color/white"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        />
    <fragment
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="0dp"
        android:layout_height="0dp" …
Run Code Online (Sandbox Code Playgroud)

android toolbar android-fragments android-jetpack-navigation

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