Scan Network Android App – google play


The target market of this application is anyone who troubleshoot network problems specially if it got any issue with smartphone.

Source code can be cloned from GitHub:

The application grant you the ability to check if a network target whether it is an IP address or a domain is reachable from the network you are in. Moreover, you can scan and find out which IP addresses are active on the network.

I intend to expand the abilities of this very awesome application to be able to scan the open ports in a target IP address and from there to try and penetrate it or perform various attacks on it (Metasploit spirit).

Challenging Issues:

1- Being economic and reduce Crashes

When you select a network to scan, it is not a good idea to do the calculations in the view itself. Creating a new Java Thread even will make the problem worse than you think. The reason is finding available IP’s is a blocking process. Therefore the app will freeze and afterward it will crash. Calling a thread is not a good idea also since if you back in history or if you open another application, this view will die and openning it will create new similar activity with new environment. what about the other thread? will, it may be still running if the android OS didn’t feel threatened with the leak of resources – which then it will kill all the inevitable processes.

the solution is to use services for each network scan, which hold the calculations. Since services doesn’t die when view is dead, a hash will hold on the found results and broadcasting them. When a new view is opened, it will have a receiver listening to the intent broadcasts comes from the relevant service.

private void publishResults(String ipaddress,String activityName,ArrayList currentlyFoundIPsList) {
//Log.i(“publishResults”, ” publishing the results: Ip Address = ” + ipaddress + ” and currently found is “+currentlyFoundIPsList.size());
//Intent intent = new Intent(activityName);
Intent intent = new Intent(“activityName”);
intent.putExtra(IP_ADDRESS, ipaddress);

intent.putStringArrayListExtra(IP_ADDRESS_CURRENTLY_FOUND, currentlyFoundIPsList);
intent.putExtra(ACTIVITY_ID, activityName);

2- Struggling with adding Action bar buttons

When I created the project, adding buttons to the action bar appeared only in the side list of the application. after digging the issue, i got that the style of the application is Appcomp which doesn’t support buttons on the action bar. no relevant answer was found on StackOverflow. Most of the answers was to add MinSdkVersion higher than 11 at the  AndroidManifest.xml
It was a total nonsense. the solution was to change the dependencies of the app by going to Module Settings(F6 in the Project and then add a support dependency higher than V13:
dependencyThe style you should use is Theme.Holo or any descendant one.

3 – Threading troubles

This Exception was the curse of anyone who tried to use thread that updates a listview:

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification.
Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.
Make sure your adapter calls notifyDataSetChanged() when its content changes.
[in ListView(2131230735, class android.widget.ListView) with Adapter(class android.widget.ArrayAdapter)]

The background thread may work fast causing the listview adapter to be flooded.
Updating the listview inside a UI Runnable block is a mandatory:

runOnUiThread(new Runnable() {
public void run() {

However it should notify the listview about the change by calling