Home » Programming » Android » Windows 8 ad hoc

Windows 8 ad hoc

In my initial stages of developing for android, I was told time and time again that using an emulator was no way to go about it. Due to my lack of understanding I decided I would use the emulator to start. Then I got tired of the slow Eclipse emulator and decided to hook up my Android phone and use it instead. I found, after watching a tutorial (The only thing that was missing in this tutorial was downloading the right sdk in the sdk manager so you may have to look that up yourself), that the phone was MUCH faster. The problem was, my app no longer would communicate to the server. This is obviously crucial to the development of the app so I did some research and found that its because of my network blocking the access to my server even while connected to the same wifi. I read that the best way to solve this problem is to create an ad hoc network. Here is where I ran into the issue that shocked me the most.

I have set up ad hoc networks time and time again in Windows 7. However, Windows 8 has taken away the easy way of setting it up (or at least the way I knew how). After a little bit of stumbling around on Windows 8, I couldn’t get past the window that said that I must be in ‘Private’ network mode in order to set up an ad hoc network. I read on some blog page that it based the selection on whether your have your file sharing or network discovery. However, no matter how much I altered the settings, I still had no success.

That is when I came across this site. While it is already on this site, I thought I would repost just in case it ever went away. There is a tool that has been implemented into windows for a while now call “Network Shell.” This tool allows you to do many things like run ad hoc, as long as your driver supports it. The down-side to this tool is that it is strictly command line based. you should have the command prompt opened as administrator before beginning (right click cmd and choose ‘as administrator’).

The first thing is to find whether your driver is capable of ad hoc. You do this through typing:

 netsh wlan show drivers 

At this point, its very helpful to have a picture to see just what I am referring too but it should have some text where somewhere it says ‘ hosted network supported : yes’.  This means that your laptop is capable of doing an ad hoc environment without making any driver changes. Otherwise, you may need to update your wireless drivers.

Next is setting up your ad hoc network. You set up this other network by typing these commands:

 netsh wlan set hostednetwork mode=allow ssid=<?>  key=<?>
netsh wlan start hostednetwork

Here you will notice the <?> in the first command. You replace these with the ssid of your choice as well as the password of your choice. Once these two commands have been run, you are ready to connect with, in my case, your android phone. By the way, all I had to do after that was change the ip address for the server and it worked great!

PS.. I also started to have problems with restarting this ad hoc network. For your information, you may have to go into your ‘device manager’ and go to your network adapters. When you get there, you expand that category and look for the virtual adapter for wifi. You right click and say ‘enable’. This at least solved my problem. The error I was getting looked like this:

The hosted network couldn’t be started. The group or resource is not in the correct state to perform the requested operation.

Hope this helps!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s