Ok, trying to set a System Setting as discussed with Erel, as talked about here: http://www.b4x.com/forum/basic4android-updates-questions/23706-enforcing-checking-time-limit-demo-program.html#post137435
My limited understanding and use of the Reflection library so far, is to assign to the Reflector.Target some object, and then use Methods on them to get whatever functionality I'm looking to have happen.
I think I understand that if I want to do something to an object that doesn't exist within B4A (not a View, etc.) that I need to use Reflector.CreateObject or CreateObject2.
I Want to create an "android.provider.Settings.System" object and then run
two methods on it:
static boolean : putLong(ContentResolver cr, String name, long value)
Convenience function for updating a single settings value as a long integer.
and
static long : getLong(ContentResolver cr, String name)
Convenience function for retrieving a single system settings value as a long.
This also means I need to create a ContentResolver, to pass as part of the args().
Soooo,
I look at the public Constructor for ContentResolver, and see that it needs a Context... so I want to do the following first:
but of course, android.content.Context isn't supported by the Reflection library... so How would I pass the android.content.Context? (which then I think I would know how to then pass other types for use in arguments, that aren't of primitive types)
But wait... I put that on the backburner.. .and try to at least set the Target of a Reflector to my "android.provider.Settings.System"
and I get: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: android.provider.Settings.System
Which I most definitely see here: Settings.System | Android Developers
:BangHead:
So, over to someone with a little more experience... as what I can find for samples, is not leading me down the right path.
Ross
My limited understanding and use of the Reflection library so far, is to assign to the Reflector.Target some object, and then use Methods on them to get whatever functionality I'm looking to have happen.
I think I understand that if I want to do something to an object that doesn't exist within B4A (not a View, etc.) that I need to use Reflector.CreateObject or CreateObject2.
I Want to create an "android.provider.Settings.System" object and then run
two methods on it:
static boolean : putLong(ContentResolver cr, String name, long value)
Convenience function for updating a single settings value as a long integer.
and
static long : getLong(ContentResolver cr, String name)
Convenience function for retrieving a single system settings value as a long.
This also means I need to create a ContentResolver, to pass as part of the args().
Soooo,
I look at the public Constructor for ContentResolver, and see that it needs a Context... so I want to do the following first:
B4X:
Dim oReflector As Reflector
Dim oContext As Object
oContext = oReflector.GetContext 'should now have an android.content.Context in it)
args(0) = oContext
types(0) = "android.content.Context"
oReflector.Target=oReflector.CreateObject2("android.content.ContentResolver", args, types)
but of course, android.content.Context isn't supported by the Reflection library... so How would I pass the android.content.Context? (which then I think I would know how to then pass other types for use in arguments, that aren't of primitive types)
But wait... I put that on the backburner.. .and try to at least set the Target of a Reflector to my "android.provider.Settings.System"
B4X:
Dim oReflector As Reflector
oReflector.Target = oReflector.CreateObject("android.provider.Settings.System")
and I get: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: android.provider.Settings.System
Which I most definitely see here: Settings.System | Android Developers
:BangHead:
So, over to someone with a little more experience... as what I can find for samples, is not leading me down the right path.
Ross