Java Function Query in Tasker

161 views
Skip to first unread message

bmp

unread,
Nov 13, 2015, 7:39:02 AM11/13/15
to Tasker

Want to test the Java code in Tasker and was trying to execute the sample code in the Tasker website itself

1  Variable Set, %service, wifi

2  Java Function, wiman = CONTEXT.getSystemService( %service )

3  Java Function, %enabled = wiman.isWifiEnabled()

 

Step 1 & 2 is not a problem ,but on step 3 I don’t get the function  isWifiEnabled for wiman ,but the default classes like clone, equals, finalize...

 

Any pointers?

Thankx in advance

Wayne Longford

unread,
Nov 13, 2015, 10:06:13 AM11/13/15
to Tasker

2  Java Function, wiman = CONTEXT.getSystemService( %service )


Try: (WifiManager) wiman = CONTEXT.getSystemService( %service ) 

bmp

unread,
Nov 13, 2015, 1:11:10 PM11/13/15
to Tasker

Thank you sir for the valuable comments.As per your suggestion the required flass functions are listing out.
Anycase ,at the end of the day ,the program is not working.
Just wondering any specific things to be loaded in Tasker before this programming or any fundamental things I am missing?
Regards,
BMP

Wayne Longford

unread,
Nov 13, 2015, 2:02:37 PM11/13/15
to Tasker
Do you mean the java function doesn't return the wifi state or that something else in your task/profile is not working?

It would be helpful for you to provide more info.
You can do this by long pressing on the profile/task then go to Menu/Export/Description to clipboard - and then paste the info here.
You may need to disable Beginner Mode before you can do that. Go to Menu/Preferences/UI

bmp

unread,
Nov 14, 2015, 9:01:18 AM11/14/15
to Tasker
Mea Culpa! Mea Culpa !!....
Sir,I was my mistake where I was giving a wrong parameter in the first statement- Thank again for patiently guiding me on this.
Anycase your typecasting statement was instrumental(WifiManager)  and not sure how it got missed in the example or was it working for other with out this typecasting .?

Wayne Longford

unread,
Nov 14, 2015, 11:52:59 AM11/14/15
to Tasker
Thank again for patiently guiding me on this.

Your welcome =)
 
Anycase your typecasting statement was instrumental(WifiManager)  and not sure how it got missed in the example or was it working for other with out this typecasting .?

I don't know the answer to this I'm afraid. Someone with more Java knowledge might be able to provide more info!

Juergen Gruen

unread,
Nov 15, 2015, 11:37:43 AM11/15/15
to Tasker
The return type of "Context.GetSystemService(string)" is "object", so you cannot use "wiman.isWifiEnabled()" without typecasting...

Juergen.
Reply all
Reply to author
Forward
0 new messages