小编the*_*ean的帖子

Google API客户端OAuth始终返回已取消

我正在尝试使用Google Fit History API,我遇到了一个问题,在我使用ConnectionResult.StartResolutionForResult提示用户使用他们的Google帐户之后,我总是会收到取消代码CANCELED,即使用户通过对话.据我所知,我已经按照此处的指南(https://developers.google.com/fit/android/get-api-key)查看了这封信.我在Developers控制台中有一个项目.我在控制台中启用了Fitness API.我在开发机器上使用调试密钥库生成了一个客户端ID.以下是开发者控制台的一些截图: 在开发者控制台中启用API的屏幕截图 开发人员控制台中OAuth客户端ID的屏幕截图

我正在使用Xamarin.Android进行编程,并按照此处的示例进行操作.(请注意,我确实安装了Xamarin.GooglePlayServices.Fitness包):https: //github.com/xamarin/monodroid-samples/tree/master/google-services/Fitness/BasicHistoryApi

以下是代码的关键区域:

    mClient = new GoogleApiClient.Builder (this)
        .AddApi (FitnessClass.HISTORY_API)
        .AddScope (new Scope (Scopes.FitnessActivityReadWrite))
        .AddConnectionCallbacks (clientConnectionCallback)
        .AddOnConnectionFailedListener (result => {
            Log.Info (TAG, "Connection failed. Cause: " + result);
            if (!result.HasResolution) {
                // Show the localized error dialog
                GooglePlayServicesUtil.GetErrorDialog (result.ErrorCode, this, 0).Show ();
                return;
            }
            // The failure has a resolution. Resolve it.
            // Called typically when the app is not yet authorized, and an
            // authorization dialog is displayed to the …
Run Code Online (Sandbox Code Playgroud)

android google-api xamarin.android xamarin google-fit

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

MvxSpinner初始值

MvxSpinner在Android中有一个MvvmCross 绑定。用户选择一个值,该值就会反映在我的属性中MealTypeSelected

<MvxSpinner
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    local:MvxBind="ItemsSource MealTypeList;SelectedItem MealTypeSelected, Mode=TwoWay" />
Run Code Online (Sandbox Code Playgroud)

微调器用于允许用户选择用餐类型(早餐,午餐,晚餐等)。进餐类型由称为的枚举表示MealType

public enum MealType {Unspecified, Breakfast, Lunch, Dinner, Snack};

我想通过将微调器初始化为基于显示时间的时间值来简化用户的操作ViewModel。因此,如果页面是在中午加载的,那么我猜您的选择应该是“午餐”。

问题是,我尝试在生命周期的不同位置设置MealTypeSelected属性ViewModel:构造函数Init,和Start。但是无论我做什么,在加载视图时,它都会将选择更改 Enum的默认值,即“ Unspecified”值。

有没有办法解决此问题并将其MvxSpinner初始化为特定值?

xamarin.android android-spinner mvvmcross xamarin

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