我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代码中始终会出现“ 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) 我已经开始使用 Android Jetpack 的导航库。到目前为止,我觉得它很容易使用。我面临的问题是工具栏。
我想要实现的是:
我尝试了很多事情,但没有成功。前两次尝试使用具有NoActionBar样式的活动。
<?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