├── .github └── workflows │ └── release.yml ├── .gitignore ├── .idea ├── .gitignore ├── .name ├── compiler.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── jarRepositories.xml ├── misc.xml └── vcs.xml ├── APManager ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── vkpapps │ │ └── apmanager │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── vkpapps │ │ └── apmanager │ │ ├── APManager.java │ │ └── DefaultFailureListener.java │ └── test │ └── java │ └── com │ └── vkpapps │ └── apmanager │ └── ExampleUnitTest.java ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── vkpapps │ │ └── wifimanager │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── vkpapps │ │ │ └── wifimanager │ │ │ ├── APDetailActivity.java │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_ap_detail.xml │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── vkpapps │ └── wifimanager │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logo.png └── settings.gradle /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Publish Bintray 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | jobs: 9 | publish: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v1 14 | - name: Set up JDK 1.8 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: 1.8 18 | - name: Grant Permission to Execute 19 | run: chmod +x gradlew 20 | - name: Publish Library 21 | env: 22 | bintrayUser: ${{ secrets.BINTRAY_USER }} 23 | bintrayApiKey: ${{ secrets.BINTRAY_API_KEY }} 24 | run: ./gradlew bintrayUpload -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | WifiManager -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 22 | 23 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 45 | 46 | 47 | 48 | 49 | 50 | 52 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /APManager/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /APManager/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | apply plugin: 'com.github.dcendents.android-maven' 5 | apply plugin: 'com.jfrog.bintray' 6 | ext{ 7 | VERSION_CODE = 2 8 | VERSION_NAME = "1.0.1" 9 | } 10 | android { 11 | compileSdkVersion 30 12 | buildToolsVersion "30.0.2" 13 | 14 | defaultConfig { 15 | minSdkVersion 21 16 | targetSdkVersion 30 17 | versionCode VERSION_CODE 18 | versionName VERSION_NAME 19 | 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | consumerProguardFiles "consumer-rules.pro" 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | } 35 | 36 | dependencies { 37 | 38 | implementation 'androidx.appcompat:appcompat:1.2.0' 39 | implementation 'com.google.android.material:material:1.2.1' 40 | testImplementation 'junit:junit:4.13.1' 41 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 42 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 43 | } 44 | 45 | ext { 46 | // This should be same as you've created in bintray 47 | bintrayRepo = 'AndroidWifiManager' 48 | 49 | // Name which will be visible on bintray 50 | bintrayName = 'APManager' 51 | 52 | // Library Details 53 | publishedGroupId = 'com.vkpapps.wifimanager' 54 | libraryName = 'Access Point Manager' 55 | artifact = 'APManager' 56 | libraryDescription = 'Access Point Manager Library' 57 | libraryVersion = VERSION_NAME 58 | version(VERSION_NAME) 59 | 60 | // Repository Link (For e.g. GitHub repo) 61 | siteUrl = 'https://github.com/vijaypatidar/AndroidWifiManager' 62 | gitUrl = 'https://github.com/vijaypatidar/AndroidWifiManager.git' 63 | githubRepository= 'vijaypatidar/AndroidWifiManager' 64 | 65 | // Developer Details 66 | developerId = 'vijaypatidar' 67 | developerName = 'Vijay Patidar' 68 | developerEmail = 'vkramotiya987@gmail.com' 69 | 70 | // License Details 71 | licenseName = 'The Apache Software License, Version 2.0' 72 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 73 | allLicenses = ["Apache-2.0"] 74 | } 75 | 76 | // This is mandatory 77 | group = publishedGroupId 78 | 79 | install { 80 | repositories.mavenInstaller { 81 | // This generates POM.xml with proper parameters 82 | pom { 83 | project { 84 | packaging 'aar' 85 | 86 | groupId publishedGroupId 87 | artifactId = artifact 88 | name libraryName 89 | description = libraryDescription 90 | url siteUrl 91 | 92 | licenses { 93 | license { 94 | name licenseName 95 | url licenseUrl 96 | } 97 | } 98 | developers { 99 | developer { 100 | id developerId 101 | name developerName 102 | email developerEmail 103 | } 104 | } 105 | scm { 106 | connection gitUrl 107 | developerConnection gitUrl 108 | url siteUrl 109 | } 110 | } 111 | } 112 | } 113 | } 114 | 115 | 116 | 117 | // Avoid Kotlin docs error 118 | tasks.withType(Javadoc) { 119 | enabled = false 120 | } 121 | 122 | // Remove javadoc related tasks 123 | task javadoc(type: Javadoc) { 124 | source = android.sourceSets.main.java.srcDirs 125 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 126 | } 127 | 128 | task sourcesJar(type: Jar) { 129 | from android.sourceSets.main.java.srcDirs 130 | getArchiveClassifier().set( 'sources') 131 | } 132 | 133 | task javadocJar(type: Jar, dependsOn: javadoc) { 134 | getArchiveClassifier().set( 'javadoc') 135 | from javadoc.destinationDir 136 | } 137 | artifacts { 138 | archives javadocJar 139 | archives sourcesJar 140 | } 141 | 142 | bintray { 143 | user = System.getenv("bintrayUser") 144 | key = System.getenv("bintrayApiKey") 145 | 146 | configurations = ['archives'] 147 | pkg { 148 | repo = bintrayRepo 149 | name = bintrayName 150 | websiteUrl = siteUrl 151 | vcsUrl = gitUrl 152 | licenses = allLicenses 153 | publish = true 154 | } 155 | } -------------------------------------------------------------------------------- /APManager/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/APManager/consumer-rules.pro -------------------------------------------------------------------------------- /APManager/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /APManager/src/androidTest/java/com/vkpapps/apmanager/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.apmanager; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.vkpapps.apmanager.test", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /APManager/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /APManager/src/main/java/com/vkpapps/apmanager/APManager.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.apmanager; 2 | 3 | import android.Manifest; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.pm.PackageManager; 8 | import android.location.LocationManager; 9 | import android.net.Uri; 10 | import android.net.wifi.WifiConfiguration; 11 | import android.net.wifi.WifiManager; 12 | import android.os.Build; 13 | import android.os.Handler; 14 | import android.os.Looper; 15 | import android.provider.Settings; 16 | 17 | import androidx.annotation.NonNull; 18 | import androidx.annotation.Nullable; 19 | import androidx.annotation.RequiresApi; 20 | import androidx.core.app.ActivityCompat; 21 | 22 | import java.lang.reflect.Method; 23 | import java.math.BigInteger; 24 | import java.security.MessageDigest; 25 | import java.security.NoSuchAlgorithmException; 26 | import java.util.Random; 27 | 28 | /** 29 | *

APManager - Access Point Manager

30 | *

31 | * APManager is a singleton utility class that help to create mobile hotspot on android device 32 | * programmatically , without taking care of android version and permission requires 33 | * needed to do the same.It supports android 5.0 and later android version. 34 | *

35 | */ 36 | public class APManager { 37 | private static APManager apManager; 38 | private final Utils utils; 39 | 40 | private APManager(Context context) { 41 | wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); 42 | locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); 43 | this.utils = new Utils(); 44 | } 45 | 46 | /** 47 | * @param context should not be null 48 | * @return APManager 49 | */ 50 | public static APManager getApManager(@NonNull Context context) { 51 | if (apManager == null) { 52 | apManager = new APManager(context); 53 | } 54 | return apManager; 55 | } 56 | 57 | private String ssid; 58 | private String password; 59 | 60 | /** 61 | * get ssid of recently created hotspot 62 | * @return SSID 63 | */ 64 | public String getSSID() { 65 | return ssid; 66 | } 67 | 68 | /** 69 | * get password of recently created hotspot 70 | * @return PASSWORD 71 | */ 72 | public String getPassword() { 73 | return password; 74 | } 75 | 76 | /** 77 | * Some android version requires gps provider to be in active mode to create access point (Hotspot). 78 | */ 79 | public static final int ERROR_GPS_PROVIDER_DISABLED = 0; 80 | public static final int ERROR_LOCATION_PERMISSION_DENIED = 4; 81 | public static final int ERROR_DISABLE_HOTSPOT = 1; 82 | public static final int ERROR_DISABLE_WIFI = 5; 83 | public static final int ERROR_WRITE_SETTINGS_PERMISSION_REQUIRED = 6; 84 | public static final int ERROR_UNKNOWN = 3; 85 | 86 | private final WifiManager wifiManager; 87 | private final LocationManager locationManager; 88 | private WifiManager.LocalOnlyHotspotReservation reservation; 89 | 90 | 91 | public Utils getUtils() { 92 | return utils; 93 | } 94 | 95 | public void turnOnHotspot(Context context, OnSuccessListener onSuccessListener, OnFailureListener onFailureListener) { 96 | boolean providerEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); 97 | 98 | if (isDeviceConnectedToWifi()) { 99 | onFailureListener.onFailure(ERROR_DISABLE_WIFI,null); 100 | return; 101 | } 102 | 103 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { 104 | if (utils.checkLocationPermission(context) && providerEnabled && !isWifiApEnabled()) { 105 | try { 106 | wifiManager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() { 107 | public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) { 108 | super.onStarted(reservation); 109 | APManager.this.reservation = reservation; 110 | try { 111 | ssid = reservation.getWifiConfiguration().SSID; 112 | password = reservation.getWifiConfiguration().preSharedKey; 113 | onSuccessListener.onSuccess(ssid, password); 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | onFailureListener.onFailure(ERROR_UNKNOWN,e); 117 | } 118 | } 119 | 120 | public void onFailed(int reason) { 121 | super.onFailed(reason); 122 | onFailureListener.onFailure(reason == ERROR_TETHERING_DISALLOWED ? ERROR_DISABLE_HOTSPOT : ERROR_UNKNOWN,null); 123 | } 124 | 125 | }, new Handler(Looper.getMainLooper())); 126 | } catch (Exception e) { 127 | onFailureListener.onFailure(ERROR_UNKNOWN,e); 128 | } 129 | } else if (!providerEnabled) { 130 | onFailureListener.onFailure(ERROR_GPS_PROVIDER_DISABLED,null); 131 | } else if (isWifiApEnabled()) { 132 | onFailureListener.onFailure(ERROR_DISABLE_HOTSPOT,null); 133 | } else { 134 | onFailureListener.onFailure(ERROR_LOCATION_PERMISSION_DENIED,null); 135 | } 136 | } else { 137 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 138 | if (!utils.checkLocationPermission(context)) { 139 | onFailureListener.onFailure(ERROR_LOCATION_PERMISSION_DENIED,null); 140 | return; 141 | } 142 | if (!utils.checkWriteSettingPermission(context)) { 143 | onFailureListener.onFailure(ERROR_WRITE_SETTINGS_PERMISSION_REQUIRED,null); 144 | return; 145 | } 146 | } 147 | try { 148 | ssid = "AndroidAP_" + new Random().nextInt(10000); 149 | password = getRandomPassword(); 150 | WifiConfiguration wifiConfiguration = new WifiConfiguration(); 151 | wifiConfiguration.SSID = ssid; 152 | wifiConfiguration.preSharedKey = password; 153 | wifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); 154 | wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN); 155 | wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA); 156 | wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); 157 | wifiManager.setWifiEnabled(false); 158 | setWifiApEnabled(wifiConfiguration, true); 159 | onSuccessListener.onSuccess(ssid, password); 160 | } catch (Exception e) { 161 | e.printStackTrace(); 162 | onFailureListener.onFailure(ERROR_LOCATION_PERMISSION_DENIED,e); 163 | } 164 | } 165 | } 166 | 167 | public void disableWifiAp() { 168 | try { 169 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { 170 | reservation.close(); 171 | } else { 172 | setWifiApEnabled(null, false); 173 | } 174 | } catch (Exception e) { 175 | e.printStackTrace(); 176 | } 177 | } 178 | 179 | public boolean isWifiApEnabled() { 180 | try { 181 | Method method = wifiManager.getClass().getMethod("isWifiApEnabled"); 182 | return (boolean) method.invoke(wifiManager); 183 | } catch (Exception e) { 184 | e.printStackTrace(); 185 | } 186 | return false; 187 | } 188 | 189 | /** 190 | * Utility method to check device wifi is enabled and connected to any access point. 191 | * 192 | * @return connection status of wifi 193 | */ 194 | public boolean isDeviceConnectedToWifi() { 195 | return wifiManager.getDhcpInfo().ipAddress != 0; 196 | } 197 | 198 | private void setWifiApEnabled(WifiConfiguration wifiConfiguration, boolean enable) throws Exception { 199 | Method method = wifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class); 200 | method.invoke(wifiManager, wifiConfiguration, enable); 201 | } 202 | 203 | public WifiManager getWifiManager() { 204 | return wifiManager; 205 | } 206 | 207 | public interface OnFailureListener { 208 | void onFailure(int failureCode,@Nullable Exception e); 209 | } 210 | 211 | public interface OnSuccessListener { 212 | void onSuccess(@NonNull String ssid,@NonNull String password); 213 | } 214 | 215 | private String getRandomPassword() { 216 | try { 217 | MessageDigest ms = MessageDigest.getInstance("MD5"); 218 | byte[] bytes = new byte[10]; 219 | new Random().nextBytes(bytes); 220 | byte[] digest = ms.digest(bytes); 221 | BigInteger bigInteger = new BigInteger(1, digest); 222 | return bigInteger.toString(16).substring(0, 10); 223 | } catch (NoSuchAlgorithmException e) { 224 | e.printStackTrace(); 225 | } 226 | return "jfs82433#$2"; 227 | } 228 | 229 | public static class Utils { 230 | public boolean checkLocationPermission(Context context) { 231 | return ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED; 232 | } 233 | 234 | public void askLocationPermission(Activity activity, int requestCode) { 235 | ActivityCompat.requestPermissions(activity, new String[]{ 236 | Manifest.permission.ACCESS_FINE_LOCATION 237 | }, requestCode); 238 | } 239 | 240 | @RequiresApi(Build.VERSION_CODES.M) 241 | public void askWriteSettingPermission(@NonNull Activity activity) { 242 | Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS); 243 | intent.setData(Uri.parse("package:" + activity.getPackageName())); 244 | activity.startActivity(intent); 245 | } 246 | 247 | @RequiresApi(Build.VERSION_CODES.M) 248 | public boolean checkWriteSettingPermission(@NonNull Context context) { 249 | return Settings.System.canWrite(context); 250 | } 251 | 252 | public Intent getTetheringSettingIntent() { 253 | Intent intent = new Intent(); 254 | intent.setClassName("com.android.settings", "com.android.settings.TetherSettings"); 255 | return intent; 256 | } 257 | 258 | public void askForGpsProvider(Activity activity) { 259 | Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 260 | activity.startActivity(intent); 261 | } 262 | 263 | public void askForDisableWifi(Activity activity) { 264 | activity.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); 265 | } 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /APManager/src/main/java/com/vkpapps/apmanager/DefaultFailureListener.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.apmanager; 2 | 3 | import android.app.Activity; 4 | import android.os.Build; 5 | import android.widget.Toast; 6 | 7 | public class DefaultFailureListener implements APManager.OnFailureListener { 8 | public static final int REQUEST_CODE_WRITE_SETTINGS=12; 9 | private final Activity activity; 10 | 11 | public DefaultFailureListener(Activity activity) { 12 | this.activity = activity; 13 | } 14 | 15 | @Override 16 | public void onFailure(int failureCode,Exception e) { 17 | APManager.Utils utils = APManager.getApManager(activity).getUtils(); 18 | switch (failureCode) { 19 | case APManager.ERROR_DISABLE_HOTSPOT: 20 | Toast.makeText(activity, "DISABLE HOTSPOT", Toast.LENGTH_LONG).show(); 21 | activity.startActivity(utils.getTetheringSettingIntent()); 22 | break; 23 | case APManager.ERROR_DISABLE_WIFI: 24 | Toast.makeText(activity, "DISCONNECT WIFI", Toast.LENGTH_LONG).show(); 25 | utils.askForDisableWifi(activity); 26 | break; 27 | case APManager.ERROR_GPS_PROVIDER_DISABLED: 28 | Toast.makeText(activity, "ENABLE GPS", Toast.LENGTH_LONG).show(); 29 | utils.askForGpsProvider(activity); 30 | break; 31 | case APManager.ERROR_LOCATION_PERMISSION_DENIED: 32 | Toast.makeText(activity, "ALLOW LOCATION PERMISSION", Toast.LENGTH_LONG).show(); 33 | utils.askLocationPermission(activity, REQUEST_CODE_WRITE_SETTINGS); 34 | break; 35 | case APManager.ERROR_WRITE_SETTINGS_PERMISSION_REQUIRED: 36 | Toast.makeText(activity, "ALLOW WRITE SYSTEM SETTINGS PERMISSION", Toast.LENGTH_LONG).show(); 37 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 38 | utils.askWriteSettingPermission(activity); 39 | } 40 | break; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /APManager/src/test/java/com/vkpapps/apmanager/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.apmanager; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | drawing

2 | ![Publish Bintray](https://github.com/vijaypatidar/AndroidWifiManager/workflows/Publish%20Bintray/badge.svg)[ ![Download](https://api.bintray.com/packages/vijaypatidar/AndroidWifiManager/APManager/images/download.svg) ](https://bintray.com/vijaypatidar/AndroidWifiManager/APManager) 3 | # APManager - Access Point Manager 4 | APManager is a library that help to create mobile hotspot on android device programmatically , without taking care of android version and permission requires to do the same.It supports android 5.0 and later android version. 5 | 6 | # Download 7 | #### Step 1 : Add the jcenter repository to your build file 8 | 9 | ```gradle 10 | allprojects { 11 | repositories { 12 | ... 13 | jcenter() 14 | } 15 | } 16 | ``` 17 | 18 | #### Step 2 : Add the dependency 19 | ```gradle 20 | dependencies { 21 | implementation 'com.vkpapps.wifimanager:APManager:1.0.0' 22 | } 23 | ``` 24 | #### Step 3 : Use in your app 25 | ##### Handle error manually 26 | ```java 27 | APManager apManager = APManager.getApManager(this); 28 | apManager.turnOnHotspot(this, new APManager.OnSuccessListener() { 29 | 30 | @Override 31 | public void onSuccess(String ssid, String password) { 32 | //write your logic 33 | } 34 | 35 | }, new APManager.OnFailureListener() { 36 | 37 | @Override 38 | public void onFailure(int failureCode, @Nullable Exception e) { 39 | //handle error like give access to location permission,write system setting permission, 40 | //disconnect wifi,turn off already created hotspot,enable GPS provider 41 | 42 | //or use DefaultFailureListener class to handle automatically 43 | } 44 | 45 | }); 46 | //use this line to turn off Hotspot 47 | //apManager.disableWifiAp(); 48 | ``` 49 | ##### Handle error automatically with inbuilt class 50 | ```java 51 | APManager apManager = APManager.getApManager(this); 52 | apManager.turnOnHotspot(this, 53 | new APManager.OnSuccessListener() { 54 | 55 | @Override 56 | public void onSuccess(@NonNull String ssid, @NonNull String password) { 57 | //write your logic 58 | } 59 | 60 | }, 61 | new DefaultFailureListener(this) 62 | ); 63 | 64 | //use this line to turn off Hotspot 65 | //apManager.disableWifiAp(); 66 | ``` 67 | # License 68 | ```txt 69 | Apache License 70 | 71 | Copyright (c) 2020 Vijay Patidar 72 | 73 | Licensed under the Apache License, Version 2.0 (the "License"); 74 | you may not use this file except in compliance with the License. 75 | You may obtain a copy of the License at 76 | 77 | http://www.apache.org/licenses/LICENSE-2.0 78 | 79 | Unless required by applicable law or agreed to in writing, software 80 | distributed under the License is distributed on an "AS IS" BASIS, 81 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 82 | See the License for the specific language governing permissions and 83 | limitations under the License. 84 | ``` -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdkVersion 30 7 | buildToolsVersion "30.0.2" 8 | 9 | defaultConfig { 10 | applicationId "com.vkpapps.wifimanager" 11 | minSdkVersion 21 12 | targetSdkVersion 30 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | } 30 | 31 | dependencies { 32 | 33 | implementation 'androidx.appcompat:appcompat:1.2.0' 34 | implementation 'com.google.android.material:material:1.2.1' 35 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 36 | implementation project(path: ':APManager') 37 | testImplementation 'junit:junit:4.13.1' 38 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 39 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 40 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/vkpapps/wifimanager/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.wifimanager; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.vkpapps.wifimanager", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/vkpapps/wifimanager/APDetailActivity.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.wifimanager; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | import androidx.appcompat.widget.AppCompatTextView; 8 | 9 | import com.vkpapps.apmanager.APManager; 10 | 11 | public class APDetailActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_ap_detail); 17 | APManager apManager = APManager.getApManager(this); 18 | 19 | AppCompatTextView textView = findViewById(R.id.apDetail); 20 | String sb = "SSID : " + 21 | apManager.getSSID() + 22 | System.lineSeparator() + 23 | "PASS : " + 24 | apManager.getPassword(); 25 | textView.setText(sb); 26 | 27 | findViewById(R.id.btnTurnOff).setOnClickListener(v -> { 28 | apManager.disableWifiAp(); 29 | startActivity(new Intent(this,MainActivity.class)); 30 | finish(); 31 | }); 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/java/com/vkpapps/wifimanager/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.wifimanager; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.widget.Toast; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.appcompat.app.AppCompatActivity; 9 | 10 | import com.vkpapps.apmanager.APManager; 11 | import com.vkpapps.apmanager.DefaultFailureListener; 12 | 13 | public class MainActivity extends AppCompatActivity implements APManager.OnSuccessListener { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | 20 | findViewById(R.id.btnTurnOn).setOnClickListener(v -> { 21 | APManager apManager = APManager.getApManager(this); 22 | apManager.turnOnHotspot(this, 23 | this, 24 | new DefaultFailureListener(this) 25 | ); 26 | 27 | }); 28 | } 29 | 30 | 31 | @Override 32 | public void onSuccess(@NonNull String ssid, @NonNull String password) { 33 | Toast.makeText(this, ssid + "," + password, Toast.LENGTH_LONG).show(); 34 | startActivity(new Intent(this, APDetailActivity.class)); 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ap_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 20 | 21 | 28 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | WifiManager 3 | Turn Off AP 4 | Turn On AP 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/test/java/com/vkpapps/wifimanager/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.vkpapps.wifimanager; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:4.1.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' 13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 18 09:08:02 IST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vijaypatidar/AndroidWifiManager/b82da420e36f9c07318b882cc7e21ff32c78697e/logo.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':APManager' 2 | include ':app' 3 | rootProject.name = "WifiManager" --------------------------------------------------------------------------------