How to connect android wifi to adhoc wifi?


Android Problem Overview

I'm new on the android system. Is this correct, the android 2.2.1 WIFI only detects non-ad hoc wireless network? I was wondering if there's a way to connect my android to an ad hoc network set-up from my laptop.

Android Solutions

Solution 1 - Android

You are correct that this is currently not natively supported in Android, although Google has been saying it will be coming ever since Android was officially launched.

While not natively supported, the hardware on every android device released to date do support it. It is just disabled in software, and you would need to enable it in order to use these features.

It is however, fairly easy to do this, but you need to be root, and the specifics may be slightly different between different devices. Your best source for more informationa about this, would be XDA developers: Most of the existing solutions are based on replacing wpa_supplicant, and is the method I would recommend if possible on your device. For more details, see

Update: Its been a few years now, and whenever I need an ad hoc network connection on my phone I use CyanogenMod. It gives you both programmatic and scripted access to these functions, and the ability to create ad hoc (ibss) networks in the WiFi settings menu.

Solution 2 - Android

If you specifically want to use an ad hoc wireless network, then Andy's answer seems to be your only option. However, if you just want to share your laptop's internet connection via Wi-fi using any means necessary, then you have at least two more options:

  1. Use your laptop as a router to create a wifi hotspot using Virtual Router or Connectify. A nice set of instructions can be found here.
  2. Use the Wi-fi Direct protocol which creates a direct connection between any devices that support it, although with Android devices support is limited* and with Windows the feature seems likely to be Windows 8 only.

*Some phones with Android 2.3 have proprietary OS extensions that enable Wi-fi Direct (mostly newer Samsung phones), but Android 4 should fully support this (source).

Solution 3 - Android

If you have a Microsoft Virtual WiFi Miniport Adapter as one of the available network adapters, you may do the following:

  • Run Windows Command Processor (cmd) as Administrator
  • Type: netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORD
  • Then: netsh wlan start hostednetwork
  • Open "Control Panel\Network and Internet\Network Connections"
  • Right-click on your active network adapter (the one that you use to connect on the internet) and then click Properties
  • Then open Sharing tab
  • Check "Allow other network users to connect..." and select your WiFi Miniport Adapter
  • Once finished, type: netsh wlan stop hostednetwork

That's it!

Source: How to connect android phone to an ad-hoc network without softwares.

Solution 4 - Android

I did notice something of interest here: In my 2.3.4 phone I can't see AP/AdHoc SSIDs in the Settings > Wireless & Networks menu. On an Acer A500 running 4.0.3 I do see them, prefixed by (*)

However in the following bit of code that I adapted from (can't remember source, sorry!) I do see the Ad Hoc show up in the Wifi Scan on my 2.3.4 phone. I am still looking to actually connect and create a socket + input/outputStream. But, here ya go:

    public class MainActivity extends Activity {

private static final String CHIPKIT_BSSID = "E2:14:9F:18:40:1C";
private static final int CHIPKIT_WIFI_PRIORITY = 1;

public void onCreate(Bundle savedInstanceState) {

	final Button btnDoSomething = (Button) findViewById(;
	final Button btnNewScan = (Button) findViewById(;
	final TextView textWifiManager = (TextView) findViewById(;
	final TextView textWifiInfo = (TextView) findViewById(;
	final TextView textIp = (TextView) findViewById(;

	final WifiManager myWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
	final WifiInfo myWifiInfo = myWifiManager.getConnectionInfo();
	WifiConfiguration wifiConfiguration = new WifiConfiguration();
	wifiConfiguration.BSSID = CHIPKIT_BSSID;
	wifiConfiguration.priority = CHIPKIT_WIFI_PRIORITY;
	wifiConfiguration.status = WifiConfiguration.Status.ENABLED;
	int netID = myWifiManager.addNetwork(wifiConfiguration);
	myWifiManager.enableNetwork(netID, true);
	textWifiInfo.setText("SSID: " + myWifiInfo.getSSID() + '\n' 
			+ myWifiManager.getWifiState() + "\n\n");
	btnDoSomething.setOnClickListener(new View.OnClickListener() {			
		public void onClick(View v) {
			clearTextViews(textWifiManager, textIp);				

	btnNewScan.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			getNewScan(myWifiManager, textWifiManager, textIp);

private void clearTextViews( {
	for(int i = 0; i<tv.length; i++){

public void getNewScan(WifiManager wm, TextView...textViews) {

	List<ScanResult> scanResult = wm.getScanResults();
	String scan = "";

	for (int i = 0; i < scanResult.size(); i++) {
		scan += (scanResult.get(i).toString() + "\n\n");


public boolean onCreateOptionsMenu(Menu menu) {
	getMenuInflater().inflate(, menu);
	return true;

Don't forget that in Eclipse you can use Ctrl+Shift+[letter O] to fill in the missing imports...

and my manifest:

    <manifest xmlns:android=""
android:versionName="1.0" >

    android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>

    android:theme="@style/AppTheme" >
        android:label="@string/title_activity_main" >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

Hope that helps!

Solution 5 - Android

You are correct, but note that you can do it the other way around - use Android Wifi tethering that sets up the phone as a base station and connect to said base station from the laptop.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCyril HoradView Question on Stackoverflow
Solution 1 - AndroidAndyView Answer on Stackoverflow
Solution 2 - AndroidSilveriView Answer on Stackoverflow
Solution 3 - Androidw35l3yView Answer on Stackoverflow
Solution 4 - AndroidChrisView Answer on Stackoverflow
Solution 5 - AndroidgbyView Answer on Stackoverflow