├── res ├── drawable │ ├── machine.png │ ├── section_header.xml │ └── details_view.xml ├── drawable-hdpi │ ├── icon.png │ ├── ic_launcher.png │ ├── ic_action_on_off.png │ └── ic_action_discover.png ├── drawable-ldpi │ ├── icon.png │ ├── ic_launcher.png │ ├── ic_action_on_off.png │ └── ic_action_discover.png ├── drawable-mdpi │ ├── icon.png │ ├── ic_launcher.png │ ├── ic_action_on_off.png │ └── ic_action_discover.png ├── drawable-xhdpi │ ├── ic_launcher.png │ ├── ic_action_on_off.png │ └── ic_action_discover.png ├── values │ ├── colors.xml │ ├── dimens.xml │ └── strings.xml ├── menu │ └── action_items.xml ├── layout-large │ └── main.xml ├── layout-land │ └── main.xml └── layout │ ├── main.xml │ ├── row_devices.xml │ ├── device_list.xml │ └── device_detail.xml ├── src └── com │ └── example │ └── android │ └── wifidirect │ ├── Utility.java │ ├── AppNetService.java │ ├── WrapAsyncTask.java │ ├── WrapRunable.java │ ├── ThreadPoolManager.java │ ├── WiFiDirectActivity.java │ ├── DeviceDetailFragment.java │ ├── WiFiDirectBroadcastReceiver.java │ ├── ConfigInfo.java │ └── DeviceListFragment.java ├── assets └── sample_file.txt ├── README.md ├── .gitignore ├── .classpath ├── project.properties ├── .project └── AndroidManifest.xml /res/drawable/machine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable/machine.png -------------------------------------------------------------------------------- /res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_on_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-hdpi/ic_action_on_off.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_action_on_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-ldpi/ic_action_on_off.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_action_on_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-mdpi/ic_action_on_off.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_discover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-hdpi/ic_action_discover.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_action_discover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-ldpi/ic_action_discover.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_action_discover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-mdpi/ic_action_discover.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_action_on_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-xhdpi/ic_action_on_off.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_action_discover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/res/drawable-xhdpi/ic_action_discover.png -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/Utility.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/Utility.java -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/AppNetService.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/AppNetService.java -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/WrapAsyncTask.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/WrapAsyncTask.java -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/WrapRunable.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/WrapRunable.java -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/ThreadPoolManager.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/ThreadPoolManager.java -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/WiFiDirectActivity.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/WiFiDirectActivity.java -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/DeviceDetailFragment.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/DeviceDetailFragment.java -------------------------------------------------------------------------------- /assets/sample_file.txt: -------------------------------------------------------------------------------- 1 | This is a sample text file for wifi_direct demo. 2 | 3 | Once the devices are connected, the server i.e. groupOwner will listen for incoming connections and write this file. -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/WiFiDirectBroadcastReceiver.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huangjunkun/WiFiDirectDemo/HEAD/src/com/example/android/wifidirect/WiFiDirectBroadcastReceiver.java -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WiFiDirectDemo 2 | ============== 3 | 4 | 5 | A android application about Wifi-Direct P2P Share your picture. 6 | Thanks. 7 | 8 | Author - Junkun Huang. 9 | Email - huangjunkun@gmail.com 10 | -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FF000000 4 | #FF111111 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/drawable/section_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 14 | 16 | 17 | -------------------------------------------------------------------------------- /res/drawable/details_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /res/menu/action_items.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-14 15 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 300dp 19 | 200dp 20 | 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.example.android.wifidirect.WiFiDirectActivity1 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /res/layout-large/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 7 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | WiFi Direct 4 | P2P On/Off 5 | Discover 6 | Connect 7 | Disconnect 8 | Send File 9 | 10 | yes 11 | no 12 | This device will act as a client. Click on Gallery button to pick a local(stored) file 13 | No devices found. Turn on P2P and perform discovery from the Action Bar 14 | Enable P2P from action bar button above or system settings 15 | "Am I the Group Owner? " 16 | ME 17 | PEERS 18 | Report IP 19 | 20 | -------------------------------------------------------------------------------- /res/layout-land/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /res/layout/row_devices.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 19 | 25 | 32 | 33 | -------------------------------------------------------------------------------- /src/com/example/android/wifidirect/ConfigInfo.java: -------------------------------------------------------------------------------- 1 | package com.example.android.wifidirect; 2 | 3 | 4 | 5 | class ConfigInfo { 6 | 7 | public static final int MSG_NULL = 20; 8 | public static final int MSG_RECV_PEER_INFO = 21; 9 | public static final int MSG_REPORT_SEND_PEER_INFO_RESULT = 22; 10 | public static final int MSG_SEND_RECV_FILE_BYTES = 23; 11 | public static final int MSG_VERIFY_RECV_FILE_DIALOG = 24; 12 | public static final int MSG_REPORT_RECV_FILE_RESULT = 25; 13 | public static final int MSG_REPORT_SEND_FILE_RESULT = 26; 14 | public static final int MSG_SERVICE_POOL_START = 27; 15 | public static final int MSG_SEND_STRING = 28; 16 | public static final int MSG_REPORT_RECV_PEER_LIST = 29; 17 | public static final int MSG_REPORT_SEND_STREAM_RESULT = 30; 18 | public static final int MSG_UPDATE_LOCAL_INFO = 31; 19 | 20 | 21 | public static final int REQUEST_CODE_SELECT_IMAGE = 50; 22 | public static final int REQUEST_CODE_SELECT_VIDEO = 51; 23 | public static final int REQUEST_CODE_SELECT_AUDIO = 52; 24 | public static final int REQUEST_CODE_SELECT_AUDIO_ARM = 53; 25 | public static final int REQUEST_CODE_SELECT_TAKE_VIDEO = 54; 26 | public static final int REQUEST_CODE_SELECT_TAKE_IMAGE = 55; 27 | 28 | public static final int COMMAND_ID_SEND_PEER_INFO = 100; 29 | public static final int COMMAND_ID_SEND_FILE = 101; 30 | public static final int COMMAND_ID_REQUEST_SEND_FILE = 102; 31 | public static final int COMMAND_ID_RESPONSE_SEND_FILE = 103; 32 | public static final int COMMAND_ID_BROADCAST_PEER_LIST = 104; 33 | public static final int COMMAND_ID_SEND_STRING = 105; 34 | 35 | public static final int LISTEN_PORT = 8988; 36 | public static final int SOCKET_TIMEOUT = 5000; 37 | 38 | } -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 25 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /res/layout/device_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 19 | 20 | 21 | 27 | 33 | 38 | 44 | 51 | 52 | 53 | 54 | 59 | 60 | 65 | 66 | 67 | 73 | 74 | 80 | 81 | -------------------------------------------------------------------------------- /res/layout/device_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 | 19 |