Gizwits App Framework (hereinafter referred to as Framework) is an open-source mobile application development framework developed based on Gizwits App SDK to achieve the SDK loading, initialization, user registration, user login, device configuration, device discovery, device connection, device listing and other basic functions. The Framework is a source code project which is available to all developers and currently supports iOS and Android platforms. App developers can create a complete App by implementing specific product control pages based on the Framework.
This guide also comes with the source code of Gizwits Gokit App, which is an example project that employs the Framework and intended for developers to achieve a rapid development.
For source code of the Framework for Android, find here:
Eclipse version: https://git.oschina.net/dantang/GizOpenSource_AppKit_Android
Android Studio version:https://github.com/gizwits/GOpenSource_AppKit_Android_AS
For source code of Gizwits Gokit App for Android, find here:
It can also be downloaded at the Download Center:
A. Library: Third-party library directory including GizWifiSDK
assets: contains UIConfig.json
B. GizOpenSourceModules: contains
The default program entry is GosUserLoginActivity in UserModule.
Gizwits AppID and AppSecret can be set in GosApplication.java file of the project.
If you use third-party authentication or push notification, it is important to ensure that the appropriate parameters are set to the same values as used in the corresponding platform. If you use the push notification, you need to uncomment the related macro line in order to enable the corresponding type of push notification. If you don’t uncomment all the related macro lines, it means you are not using any third-party push notification at the time. Only one type of third-party push notifciation is supported at the same time, hence don’t uncomment all third-party push notification macro lines.
Configurable parameters are:
Attention:
1) The code provided in the Framework project implements the redirection to the control page without any modification. You only need to focus on the logic of the operation pages. If you want to click a device in the device list page and jump to the view you created, modify the corresponding redirection parameters in the GosDeviceListActivity.java file. Please modify the class definition of the target view as shown in the figure. If you use the blank page (GosDeviceControlActivity) provided by default to create the control page, you can skip this step.
2) Register the device listener in the control page, and implement its callback, as shown in Figure:
It is used to receive the device state change notification reported by the Gizwits App SDK, which will be parsed in order to update the page.
3) Set the listener for the current device in the control page, for example:
1 | device.setListener(gizWifiDeviceListener); |
4) To implement the command issuing, you need to call the interface method of the GizWifiDevice instance in the Gizwits App SDK:
1 | device.write(concurrentHashMap ,0); |
For detailed parameter explanation, see the guide to Gizwits App SDK.
5) When exiting the control page, you need to unsubscribe from the current device, and call the interface method of the GizWifiDevice instance in the Gizwits App SDK with the parameter set to False:
1 | device.setSubscribe(false); |
For the addition or modification of an list item in the settings page, you need to add the corresponding control in activity_gos_settings.xml and add the corresponding event in the GosSettingsActivity.java file in the module (SettingsModule).
A. Which Android versions does the Framework support?
Currently it supports Android 4.0 and higher.
B. How to update the version number
Modify the versionName in the AndroidManifest.xml file of the project so as to change the version number display in the SettingsModule module.
C. How to configure the push notification(the following uses Jiguang push notification as example)
Make sure the package name in the AndroidManifest.xml file matches the application package name you used when you applied for the push notification service, which is shown as below.
Besides, modify the corresponding settings for the push notification in the project’s AndroidManifest.xml file.
1)
1 | <permission android:name=”your App package name.permission.JPUSH_MESSAGE” android:protectionLevel=”signature” /> |
(See line 13 of the AndroidManifest.xml file in the Framework)
2)
1 | <uses-permission android:name=”your App package name.permission.JPUSH_MESSAGE” /> |
(See line 17 of the AndroidManifest.xml file in the Framework)
3)
Under DaemonService
1 | <category android:name="your App package name" /> |
(See line 159 of the AndroidManifest.xml file in the Framework)
4)
Under PushPeceiver
1 | <category android:name=”your App package name” /> |
(See line 170 of the AndroidManifest.xml file in the Framework)
5)
Under PushActivity
1 | <category android:name="your App package name" /> |
(See line 193 of the AndroidManifest.xml file in the Framework)
6)
Under JPushReceiver
1 | <templategory android:name="your App package name" /> |
(See line 224 of the AndroidManifest.xml file in the Framework)
7)
1 | <meta-data android:name=”JPUSH_APPKEY” android:value=”Your AppKey” /> |
(See line 240 of the AndroidManifest.xml file in the Framework)
See Gizwits App Code Auto-Generator to learn about the functionality of the automatically generated App code.
See “Gizwits App Framework” to grasp
See “App Development SDK” to develop your IoT App
More application development guides