- Optimize SDK init process.
- Fixed some bugs.
- Fixed EAP WiFi bugs.
- Download the newest version of SDK demo from the Official Website Of WeShare SDK or Github
- Note: Since the SDK demo is structured of Android Studio, the demo should be opened with Android Studio. Error will occur if open with eclipse.
dependencies { compile 'com.yiba:wifisdk:latest.release' //The latest.release refers to the newest version number. //It may also refers to the a specific version number, for example 2.1.5 }
To check the newest version number, please click jcenter
Please see a sample of the newest version as follows:
//Add this code in your Application class WiFiSDKManager.getInstance().init(getApplicationContext());
Intent intent = new Intent( MainActivity.this , YIbaWifiActivity.class) ; startActivity( intent );
4、Common API instructions(Please note: The API below must be used in Android main Thread or mistakes will appear)
//Set token SDK. please go to the official website (http://www.pegasus-mobile.com/) to get. //If the token is not set, you will not be able to get shared WiFi; SDK's partial functionality will not be used. WiFiSDKManager.getInstance().setToken( this , "your app token"); //Get shared WiFi notification status: //true:On false:Off Default setting:true. WiFiSDKManager.getInstance().getSharedWifiToggle( this ) ; //Get shared WiFi notification status: //true:On false:Off Default setting:true //If you set as false, then you will not receive any notifications of free WiFi. WiFiSDKManager.getInstance().setSharedWifiToggle( this , true ); //Get open WiFi notification status: //true:On false:Off Default setting:true WiFiSDKManager.getInstance().getOpenWifiToggle( this ) ; //Turn on/off open WiFi notification status: //true:On false:False Default setting:true //If you set as false, then you will not receive any notifications of open WiFi. WiFiSDKManager.getInstance().setOpenWifiToggle( this , true ); //Get the notification bar display status: //true:On false:Off Default setting:true WiFiSDKManager.getInstance().getNotificationToggle( this ) ; //Set the notification bar display status: //true:On false:Off Default setting:true //If the display status is set as false, the wifi notification in the notification center will disappear. WiFiSDKManager.getInstance().setNotificationToggle( this , true ); //finish YIbaWifiActivity WiFiSDKManager.getInstance().setYibaActivityFinish( context );
//Close Share WiFi notification WiFiSDKManager.getInstance().setSharedWifiToggle( this , false ); //Close Open WiFi notification WiFiSDKManager.getInstance().setOpenWifiToggle( this , false );
public class NotificationReveicer extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); //IntentConstant.ACTION_YIBA_WIFI_NOCIFICATION is the value of the Intent of our definition of action if (IntentConstant.ACTION_YIBA_WIFI_NOCIFICATION.equals(action)) { //IntentConstant.NOTIFICATION_JSON_DATA is the data we passed through Intent, the data is JSON //JSON data sample:{"type":0,"count":1} String json = intent.getStringExtra(IntentConstant.NOTIFICATION_JSON_DATA); ... //You can write custom notification code here } } }
JSON data sample, as:{"type":0,"count":1}
type value of 0, indicating that the Share WiFi type; type value of 1, indicating that the type of Open WiFi.
The count value indicates the number of WiFi types.
<receiver android:name=".NotificationReveicer"> <intent-filter> <action android:name="com.yiba.action.ACTION_YIBA_WIFI_NOTIFICATION"/> </intent-filter> </receiver>
In your project create Layout XML File: yiba_wifi_custom_layout.xml
For example:
Please note:
- The name of the Layout XML File must be: yiba_wifi_custom_layout.xml and cannot be changed.
- Your project ID must contain android:id="@+id/yiba_custom_layou_fram". This cannot be deleted or changed. The function of the ID is to control the click event of back button and finish current activity
In your project create a Layout XML File: yiba_wifi_custom_setting_layout.xml
For example:
Please note:
- The name of the Layout XML File must be yiba_wifi_custom_setting_layout.xml and cannot be changed
- Your project ID must contain android:id="@+id/yiba_custom_layou_setting". This cannot be deleted or changed. The function of the ID is to control the click event of back button and finish current activity.
1、Add in your app module's AndroidManifest.xml
<!-- Customize the broadcast receiver --> <receiver android:name=".YibaReceiver" android:enabled="true" android:exported="true"> <intent-filter > <action android:name="yiba_activity_back_onclick"/> </intent-filter> </receiver>
2、Create a new YibaReceiver class
public class YibaReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ( intent == null ) return; if( TextUtils.equals(intent.getAction(), "yiba_activity_back_onclick")) { //the back image is clicked } } }
-keep class android.support.v7.**{*;} -keep class android.support.v4.**{*;}

