Android 6.0 async command not working.

GaganSinghGaganSingh USUniversity ✭✭✭

Im having issues running the following code on my nextbit robin running android 6.1.1. The command doesn't execute.
But it works fine on my galaxy note 3 running android 5.0. '
It also works in a nexus 4 emulator running android 6.0.
And It works on my nextbit robin running android 6.1.1 only if i remove async.
I'm not sure if its a device or android version related issue.

LoginCommand = new RelayCommand(async() => { });

Are there some permissions missing or settings i need to add to the device?

Tagged:

Answers

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @GaganSingh - on the specific device that is failing, do you have logs from logcat? This may help see what is happening. Maybe some form of threading issue?

  • GaganSinghGaganSingh USUniversity ✭✭✭

    There aren't any messages that stand out on the logcat. Its just a bunch of random stuff regarding the device and a little from the app. And nothing happens when i press the button, no response or anything in the logcat. No errors or warning messages. It just never reaches the button click code.

  • JohnHardmanJohnHardman GBUniversity mod

    @GaganSingh

    Just to clarify - the RelayCommand you are using is the one from XLabs (source at https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/XLabs.Core/RelayCommand.cs ) ?

    When you say it isn't working, is there more to the code than shown above? Are you doing something in the action etc? Have you implemented CanExecute?

    What happens when it doesn't work?

  • GaganSinghGaganSingh USUniversity ✭✭✭

    No, the relaycommand is from MVVM Light. I apologize, i should have clarified.
    That is all the code that is producing the issue.
    I am doing something in the action but the code is never reached. It never hits the breakpoint inside of the relaycommand.
    I have not implemented CanExecute.

    Nothing happens when it doesnt work. I dont know how to debug if there are no exceptions or anything in the log.

    LoginCommand = new RelayCommand(async() => { IsBusy = true; if (!string.IsNullOrEmpty(UserID) || !string.IsNullOrEmpty(Password) || (!string.IsNullOrEmpty(UserID) && !string.IsNullOrEmpty(Password))) { var userInfo = await httpClient.ValidateUser(UserID, Password); if (userInfo == null) // TODO: fix { IsBusy = false; await App.Current.MainPage.DisplayAlert("Invalid User ID or Password", "Please try again.", "Ok"); } else { IsBusy = false; _navigationService.ReplacePageWith(Locator.RootPage, userInfo.CustomerId); } } else { IsBusy = false; await App.Current.MainPage.DisplayAlert("User ID or Password is empty", "Please enter both User ID and Password", "Ok"); } });

    It never hits the breakpoint on IsBusy

  • NMackayNMackay GBInsider, University mod

    @GaganSingh

    Strange, might be one worth running by Laurent. Certainly in Sims and hardware 6.x S7's the apps I've done with Forms & MVVM Light has been okay running packages as signed APK's.

    Would be worth seeing if you get the same issues with a viewmodel not inheriting ViewModelBase and just a regular async Forms command first to see it's an issue with RelayCommand.

  • GaganSinghGaganSingh USUniversity ✭✭✭

    Alright, I'll give that a shot sometime tomorrow. Thank you!

  • GaganSinghGaganSingh USUniversity ✭✭✭
    edited June 2016

    You were right @NMackay, something weird is happening with the RelayCommand.
    The following code works fine on my Nextbit Robin running android 6.0.1. (my initial post says 6.1.1, that is incorrect).

    LoginCommand = new Command(async() =>
    {
        IsBusy = true;
    .
    .
    .
    });
    

    What is the main difference between the RelayCommand and Command? I'll try messaging Laurent and see what he says.

Sign In or Register to comment.