Detect Available Wifi Connection

404 views
Skip to first unread message

Joelon bitmal

unread,
Oct 14, 2015, 6:34:41 AM10/14/15
to AndroidScript
hi to all droid script users, im new in droidscript

i just want to know on how to detect available wifi connections and show their mac address?

thanks id advance

Chris Hopkin

unread,
Oct 15, 2015, 4:55:58 AM10/15/15
to AndroidScript
Hi Joelon

Welcome to the DroidScript Group :)

Detecting Wifi networks is not supported right now, but would be nice to have. You can tell us about features you would like to see by posting in the 'Tell us what you want' thread.

In the meantime, it should at least be possible to view the available Wifi networks in the Android Wifi settings page, using app.SendIntent:

function ShowWifiSettings()
{
   
var packageName = "com.android.settings";
   
var className = "com.android.settings.wifi.WifiSettings";
   
var action = "android.intent.action.VIEW";
   
var category = null;
   
var uri = null;
   
var type = null;
   
var extras = null;
   
    app
.SendIntent(packageName, className, action, category, uri, type, extras);
}

Thanks

Chris

Ricky

unread,
Oct 19, 2015, 5:02:19 PM10/19/15
to AndroidScript
Hi Chris,
Can u elaborate more on this like i want to select the set up wifi hotspot or enable wifi hotspot in TetheringSettings.

Can you give us sample code?
This would be a great help.

Thanks and Regards,
Ricky

Chris Hopkin

unread,
Oct 20, 2015, 4:35:17 AM10/20/15
to AndroidScript
Hi Ricky

DroidScript doesn't have the ability to set up or enable Wifi hotspots itself right now, but using Intents you can launch the appropriate Android settings page, to allow the user to manually change the settings.

Here is an example showing how to open specific settings pages, including the Tethering settings:

function OnStart()
{
    lay
= app.CreateLayout( "linear", "VCenter,FillXY" );

   
//Create a button for Wifi Settings.
    btn
= app.CreateButton( "Wifi Settings", 0.4 );
    btn
.SetMargins( 0, 0.025, 0, 0.025 );
    btn
.SetOnTouch( OpenWifiSettings );
    lay
.AddChild( btn );
 
   
//Create a button for Tethering Settings.
    btn
= app.CreateButton( "Tethering Settings", 0.4 );
    btn
.SetMargins( 0, 0.025, 0, 0.025 );
    btn
.SetOnTouch( OpenTetheringSettings );
    lay
.AddChild( btn );
 
   
//Create a button for Bluetooth Settings.
    btn
= app.CreateButton( "Bluetooth Settings", 0.4 );
    btn
.SetMargins( 0, 0.025, 0, 0.025 );
    btn
.SetOnTouch( OpenBluetoothSettings );
    lay
.AddChild( btn );
 
    app
.AddLayout( lay );
}

function sendIntent( packageName, className )
{

   
var action = "android.intent.action.VIEW";
   
var category = null;
   
var uri = null;
   
var type = null;
   
var extras = null;
   
    app
.SendIntent(packageName, className, action, category, uri, type, extras);
}

function OpenWifiSettings()
{
    sendIntent
( "com.android.settings", "com.android.settings.wifi.WifiSettings" );
}

function OpenTetheringSettings()
{
    sendIntent
( "com.android.settings", "com.android.settings.TetherSettings" );
}

function OpenBluetoothSettings()
{
    sendIntent
( "com.android.settings", "com.android.settings.bluetooth.BluetoothSettings" );
}

Thanks

Chris

Joelon bitmal

unread,
Oct 26, 2015, 6:59:36 AM10/26/15
to AndroidScript
thank you, i will try it

Joelon bitmal

unread,
Oct 26, 2015, 7:02:27 AM10/26/15
to AndroidScript
how about in connecting to a wireless access?

Chris Hopkin

unread,
Oct 26, 2015, 7:52:56 AM10/26/15
to AndroidScript
Hi Joelon

What I have mentioned in my previous posts will open up Wifi Connection settings and allow you to manually connect to a Wifi network. But connecting to a specific Wifi network directly from DroidScript is not currently supported.

Thanks

Chris

Netpower8

unread,
Nov 24, 2015, 11:36:06 AM11/24/15
to DroidScript
i would like to say thanks for the code sample...

Ron Michel

unread,
Jan 19, 2017, 12:58:16 PM1/19/17
to DroidScript
i am excited to check this out, could we get a list of ssid and security type as strings or a .list ?

Steve Garman

unread,
Jan 19, 2017, 1:14:23 PM1/19/17
to DroidScript
Ron,
It is a good idea to look at old posts in the forum when getting to grips with DroidScript.

However, if you are looking at a topic from 2015, please look through the whole topic before asking questions.

All that sample code does is to open the standard Android WiFi Settings menu.

Reply all
Reply to author
Forward
0 new messages