R RichyK68 Active Member Licensed User Longtime User Oct 23, 2013 #1 Hi all, I'm trying to get access to the android.app.UiModeManager object which apparently cannot be created, but must be retrieved via Context.getSystemService(Context.UI_MODE_SERVICE) but how on earth do I do this in Basic4Android? Thank you, Richard
Hi all, I'm trying to get access to the android.app.UiModeManager object which apparently cannot be created, but must be retrieved via Context.getSystemService(Context.UI_MODE_SERVICE) but how on earth do I do this in Basic4Android? Thank you, Richard
R RichyK68 Active Member Licensed User Longtime User Oct 23, 2013 #2 It can be done through the reflector object, like this: Dim r As Reflector r.Target = r.GetContext Dim UIManager As Object UIManager = r.RunMethod2("getSystemService", "uimode", "java.lang.String") This returns a reference UiModeManager. It's a shame that the Driving Mode ability cannot be turned on and off via enableCarMode and disableCarMode. r.Target = UIManager r.RunMethod2("enableCarMode" ,0 , "java.lang.int") does not throw an error but does not enable Driving Mode on the Samsung Galaxy S4. This may be because Samsung prohibit apps from doing this or I'm just doing it completely wrong Richard Upvote 0
It can be done through the reflector object, like this: Dim r As Reflector r.Target = r.GetContext Dim UIManager As Object UIManager = r.RunMethod2("getSystemService", "uimode", "java.lang.String") This returns a reference UiModeManager. It's a shame that the Driving Mode ability cannot be turned on and off via enableCarMode and disableCarMode. r.Target = UIManager r.RunMethod2("enableCarMode" ,0 , "java.lang.int") does not throw an error but does not enable Driving Mode on the Samsung Galaxy S4. This may be because Samsung prohibit apps from doing this or I'm just doing it completely wrong Richard
Erel B4X founder Staff member Licensed User Longtime User Oct 23, 2013 #3 I tried your code here on a Nexus 4 and it works correctly. The device switches to car mode. Upvote 0
R RichyK68 Active Member Licensed User Longtime User Oct 23, 2013 #4 Sorry, yes, I've just found that it does actually turn car mode on, but it's driving mode I need to turn on this is a feature of the S3 and S4, but car mode is not the same thing sadly. I'm still googling this stuff though but if you have any ideas, I'd love to hear Richard Upvote 0
Sorry, yes, I've just found that it does actually turn car mode on, but it's driving mode I need to turn on this is a feature of the S3 and S4, but car mode is not the same thing sadly. I'm still googling this stuff though but if you have any ideas, I'd love to hear Richard