Android Question [solved]How to write in B4A: mContext.getContentResolver().call()

flylg999

Member
Licensed User
Longtime User
The java code is :
Java:
CONTENT_URI_SWITCH_SYSTEM = Uri.parse("content://com.xdja.switchsystem.assistantprovider")

 Bundle bundle = new Bundle();
 bundle.putBoolean("is_switchable", p0);
 mContext.getContentResolver().call(CONTENT_URI_SWITCH_SYSTEM, "setSwitchable", null, bundle);

Can anyone help me in using it in B4A,Thanks a lot!
 

teddybear

Well-Known Member
Licensed User
The simplest way is to use inline java and then call it by javaobject.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
You can probably do it with JavaObject.
Dim ctx As JavaObject
ctx.IntializeContext
ctx.RunmethodJO("getContentResolver", Null).Runmethod("call", array.......

Something like the above I guess.
Not sure in what class CONTENT_URI_SWITCH_SYSTEM is - you might need to use another javaobject to get access to the enum field.
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
Using JavaObject try:
B4X:
' Create the JavaObject for Uri
Dim Uri As JavaObject
Uri.InitializeStatic("android.net.Uri").RunMethod("parse", Array("content://com.xdja.switchsystem.assistantprovider"))

' Create the Bundle
Dim bundle As JavaObject
bundle.InitializeNewInstance("android.os.Bundle", Null)
bundle.RunMethod("putBoolean", Array("is_switchable", p0))

' Get the ContentResolver and call the method
Dim mContext as JavaObject
mContext.initializeContext
Dim contentResolver As JavaObject
contentResolver =mContext.RunMethod("getContentResolver", Null)
contentResolver.RunMethod("call", Array(CONTENT_URI_SWITCH_SYSTEM, "setSwitchable", Null, bundle))
CONTENT_URI_SWITCH_SYSTEM has to be defined whether a constant or part of an enumeration.
 
Upvote 0

flylg999

Member
Licensed User
Longtime User
Thanks!
 
Upvote 0

flylg999

Member
Licensed User
Longtime User
I'll try it right away ,Thanks!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…