locked
Is it possible to update message or send back data in specific code by Dependency Injection? RRS feed

  • Question

  • User201534 posted

    The situation is that, I am implementing to check location permission runtime (Android 6.0) in Xamarin.Form by using Dependency Injection. As we all know, when ask for the permission, the Android system will pop-up a dialogue to ask Allow Permission. After you click the Allow, the callback function will be invoked

    public override async void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults){
        switch (requestCode)
            {
                case RequestAccessWifiStateCode:
                    {
                        if (grantResults[0] == (int)Permission.Granted)
                        {   
                ///do something?
            }
            else{
                ///do something?
            }
        }   
        }
    }
    

    The question is : How can I update the UI or the data or return some value to the Form in this callback? because this dialogue is the system level which cannot be modified.

    Official Doc: Note: When your app calls requestPermissions(), the system shows a standard dialog box to the user. Your app cannot configure or alter that dialog box. If you need to provide any information or explanation to the user, you should do that before you call requestPermissions(), as described in Explain why the app needs permissions.

    Tuesday, March 29, 2016 12:02 PM

Answers

  • User76049 posted

    https://github.com/xamarin/plugins

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, March 29, 2016 12:43 PM
  • User2148 posted

    http://motzcod.es/post/133939517717/simplified-ios-android-runtime-permissions-with

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, March 29, 2016 12:50 PM

All replies

  • User166393 posted

    You have to use custom renderer of your UI which will will be implemented in your Android. Add an extra property to the view and override that property in Android.

    So when you get that permission, the function in your android will be able to update the UI.

    Tuesday, March 29, 2016 12:05 PM
  • User2148 posted

    For permission exists a @JamesMontemagno plugin that works fine, take a look

    Tuesday, March 29, 2016 12:22 PM
  • User166393 posted

    @AlessandroCaliaro What is the link for that ?

    Tuesday, March 29, 2016 12:42 PM
  • User76049 posted

    https://github.com/xamarin/plugins

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, March 29, 2016 12:43 PM
  • User166393 posted

    Ok the permissions plugin.

    Tuesday, March 29, 2016 12:49 PM
  • User2148 posted

    http://motzcod.es/post/133939517717/simplified-ios-android-runtime-permissions-with

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, March 29, 2016 12:50 PM
  • User201534 posted

    @Maharshi.5212 said: You have to use custom renderer of your UI which will will be implemented in your Android. Add an extra property to the view and override that property in Android.

    So when you get that permission, the function in your android will be able to update the UI.

    I think this is another solution for that, but let me try the plugin first~~ thanks

    Tuesday, March 29, 2016 12:54 PM
  • User201534 posted

    @AlessandroCaliaro said: http://motzcod.es/post/133939517717/simplified-ios-android-runtime-permissions-with

    Thanks let me try it~

    Tuesday, March 29, 2016 12:55 PM
  • User201534 posted

    @NMackay said: https://github.com/xamarin/plugins

    Thanks let me try it~

    Tuesday, March 29, 2016 12:55 PM