More articles like this, you can visit HUAWEI Developer Forum and Medium.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
In this article, we will learn how to implement Huawei Share Kit in the android project.
Huawei Share Kit provides an easy interface to use so that it can share images, videos, and docs, etc. It delivers stable file transfer speeds that can exceed 80 Mbps if the third-party device and environment allow.
Introduction:
1. As a cross-device file transfer solution, Huawei Share uses Bluetooth to discover nearby devices and authenticate connections, then sets up peer-to-peer Wi-Fi channels, so as to allow file transfers between phones, PCs, and other devices.
2. To ensure user experience, Huawei Share uses reliable core technologies in each phase of file transfer.
Devices are detected using in-house bidirectional device discovery technology, without sacrificing the battery or security
Connection authentication using in-house developed password-authenticated key exchange (PAKE) technology
File transfer using high-speed point-to-point transmission technologies, including Huawei-developed channel capability negotiation and actual channel adjustment
Let’s see the working principles:
Integration part:
Huawei Share kit provides two types of implementation in which first implement depend on Huawei (Sender) to Huawei (Receiver) devices.
The second type of implementation which is based on the Android device (Sender) to Huawei device (Receiver).
In this article, we will implement the second type of implementation which is not available on any documentation or code lab.
But the first type of implementation is already provided in Huawei code lab with sample code.
What You Will Need?
Hardware Requirements
A computer (desktop or laptop) that runs Windows 7 or Windows 10
A Huawei phone (with the USB cable), which is used for debugging
A third-party Android device, which is used for debugging
Software Requirements
JDK 1.8 or later
Android API (level 26 or higher)
EMUI 10.0 or later
Let’s create a Sample Demo:
1. Create an Android Studio project:
2. Enter the file name and project location and click Finish:
3. Add Share SDK in the project:
4. We need to add the code repository to the project root directory gradle.
Code:
maven {
url 'http://developer.huawei.com/repo/'
}
5. We need to add the following dependencies in our app gradle.
Code:
dependencies {
implementation files('libs/sharekit-1.0.1.300.aar')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:localbroadcastmanager:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.google.guava:guava:24.1-android'
}
Note: You need to raise a ticket to get Share Kit SDK “sharekit-1.0.300.aar” file
Click on the below link and raise your ticket.
https://developer.huawei.com/consumer/en/support/feedback/#/
6. We need to add two permission to our android project.
Code:
android.permission.READ_EXTERNAL_STORAGE
android.permission.ACCESS_FINE_LOCATION
7. Click Sync now or Sync Project with Gradle Files to build a project.
We will cover code implementation in the next part of this article.
For your information, I will show you the final output of this sample.
Android device (Sender):
Huawei device (Receiver):
If you have any doubts or queries. Please leave your valuable comment in the comment and ask your question in HUAWEI Developer Forum.
Related
This is originally from HUAWEI Devloper Forum
Forum link: https://forums.developer.huawei.com/forumPortal/en/home
This article provides tips for integrating HUAWEI Windows Share Kit, with the goal of accelerating the integration process.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
As introduced in the Share Kit | Fully-Open HUAWEI Windows Share Kit Unveiled, Offering a New Paradigm for Phone-PC File Transfers, HUAWEI Windows Share Kit is designed to facilitate quick wireless transfers between Huawei phones and Windows PCs. By integrating Huawei Share capabilities into Windows PC apps, developers can facilitate high-speed file transfers between Huawei phones and Windows PCs.
Next, we'd like to share some tips for integrating HUAWEI Share Kit into Windows PC apps.
l Check whether your device meets the specification requirements. Currently, only devices that run Windows 10, and come in any of the following network adapters, are supported:
- Intel(R) Wi-Fi 6 AX201
- Intel Dual Band Wireless-AC 9560
- Intel Dual Band Wireless-AC 8275
- Intel Dual Band Wireless-AC 8265
- Intel Dual Band Wireless-AC 8260
l To determine whether your device's network adapter meets the requirements, check the network adapter ID. (In later versions, you can also do so by calling the specific API.)
Go to Start > Run, enter CMD, and click OK.
In the command prompt window, enter IPCONFIG /ALL and press Enter.
The 12-digit code displayed to the right of Physical Address is the ID of the network adapter on the computer.
Make sure that the compiler and compilation settings are consistent, as the APIs are provided using static linking, and message callback is implemented by directly exporting classes. Please remain aware of the scope of the exported class object, in order to prevent unnecessary breakdowns or API calling failures from occurring.
Folder-based sharing is currently not supported. An I/O error message will display when attempting to share folders. It is recommended that you display a message to warn the user in advance of this issue, when they select a folder to share.
The discovery module is based on Bluetooth BLE advertising. It discovers a target device (a Huawei phone) for file transmission by using the BLE advertising channel. In order to avoid unnecessary resource consumption, the advertising interval and time should be properly managed.
I did not know we could use Share kit with windows apps. This is a great tutorial.
Recently, it is found that AppGallery Connect Remote Configuration starts to support Cordova. The integration is rather simple, let’s have a try.If you want to quickly experience this service, see the demo on GitHub.
Integration Procedure
1. Create a project directory on your computer, run the following npm command to install Cordova.
npm install -g cordova
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Create a project and enable Remote Configuration.
a) Create an Android app in AppGallery, add it to a project, enable Remote Configuration, and add a parameter.
b) Run the following command to create a Cordova project. In this example, name the project RemoteConfig.
cordova create RemoteDemo com.huawei.cordova.remoteconfig RemoteConfig Creating a new cordova project.
c) Add an app platform to the project.
In the project directory, run cordova platform add android to add the Android platform.
Run cordova platform -l to view the supported platforms.
d) Go to Project settings in AppGallery Connect, download the agconnect-services.json file, and add the file to the android/app directory of your project.
e) Install the AppGallery Connect plug-in.
cordova plugin add @Cordova-plugin-agconnect/remoteconfig --save
After the plug-in is installed, you can view it in the plugins directory.
Add the AppGallery Connect plug-in address to app/build.gradle.
3. Use the Remote Configuration service.
1. Fetch data from the cloud. The data takes effect this time.
Call the fetch API to fetch parameter values from the cloud, and call the apply API to make them take effect.
You can view the fetched parameter values on the cloud in log information.
The other values displayed in log information are local ones.
2. Fetch the cloud data and make the parameter values fetched last time take effect.
Replace the fetch API with applyLastFetch to fetch data that is fetched from the cloud last time.
3. Clear the data.
Call the clearAll API to clear the cached data that is fetched earlier.
4. Fetch the value of a key from the cloud.
Call getValue to fetch related data from the cloud.
4. Compile and install an app package.
Run the cordova build android command to compile the project.
Find the APK package in the build folder in the android directory.
For more details, please check:
Cordova documentation:
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html
Remote Configuration API Reference:
https://github.com/AppGalleryConnect/agc-demos/tree/main/Cordova/agc-remoteconfig-cordova
Remote Configuration Demo:
https://github.com/AppGalleryConnect/agc-demos/tree/main/Cordova/agc-remoteconfig-cordova
Introduction
In this article, we will learn how to add Push kit into our Unity Game. Push notifications are those notifications that we receive on our cell phone, smartwatch or computer with a message informing us about an event or encouraging us to take a certain action. While we usually take more time to read an email, we do the opposite with notifications: we respond to the stimulus by seeing them quickly (and it is that many times, to see a push it is not even necessary to unlock our screen). Thus, it is possible to take advantage of push notifications as a direct communication channel with our users, and they are a fundamental tool when it comes to generating engagement and building a lasting relationship.
Implementation Steps
1. Creation of our App in App Gallery Connect
2. Evil Mind plugin Integration
3. Configuration in Unity
4. Creation of the scene
5. Coding
6. Configuration for project execution
7. Final result
App Gallery Connect Configuration
Creating a new App in the App Gallery connect console is a fairly simple procedure but requires paying attention to certain important aspects.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Once inside the console we must create a project and to this project we must add an App.
When creating our App we will find the following form. It is important to take into account that the category of the App must be Game.
Once the App is created, it will be necessary for us to activate the Account Kit in our APIs, we can also activate the Game service if we wish.
HUAWEI Push Kit establishes a messaging channel from the cloud to devices. By integrating Push Kit, you can send messages to your apps on users' devices in real time.
Once this configuration is completed, it will be necessary to add the SHA-256 fingerprint, for this we can use the keytool command, but for this we must first create a keystore and for this we can use Unity.
Remember that we must change the platform we are on since normally Unity will always assign us as a PC platform.
Once the keystore is created we must open the console, go to the path where the keystore is located and execute the following code. Remember that to use this command you must have the Java JDK installed.
Once inside the route
Keytool -list -v -keystore yournamekey.keystore
This will give us all the information in our keystore, we obtain the SHA256 and add it to the App.
Unity Evil Mind Plugin configuration
We have concluded the creation of the App, the project and now we know how we can create a keystore and obtain the sha in Unity.
In case you have not done it now we must create our project in Unity once the project is created we must obtain the project package which we will use to connect our project with the AGC SDK. first of all let's go download the Evil Mind plugin.
GitHub - EvilMindDevs/hms-unity-plugin
Contribute to EvilMindDevs/hms-unity-plugin development by creating an account on GitHub.
github.com
In the link you can find the package to import it to Unity, to import it we must follow the following steps.
Download the .unity package and then import it into Unity using the package importer.
Once imported, you will have the Huawei option in the toolbar, we click on the option and add the data from our App.
Once we have imported the plugin we will have to add the necessary data from our App Gallery App and place it within the
required fields of the Unity plugin. Well, now we have our App Gallery App connected to the Unity project.
Now we can add the Push Notifications prefab to our scene remember that to do this we must create a new scene,
for this example we can use the eschena that the plugin provides.
For more, you can check https://forums.developer.huawei.com/forumPortal/en/topic/0202457956096970035
Why thus p40 pro giveaway date is extending every time?
YUAman said:
Why thus p40 pro giveaway date is extending every time?
Click to expand...
Click to collapse
Hi, you mean? I can not understand.
Introduction
Huawei provides various services for developers to make ease of development and provides best user experience to end users. In this article, we will be integrating following kits:
Ads Kit
Game services
Analytics Kit
Location Kit
Push Kit
We will learn to integrate above HMS Kits in Unity game development using official plugin. And by integrating in single application gives experience the ease of development and give best user experience and showcases stability of the kits, and how we can use kits efficiently to make users experience the best of it.
Development Overview
You need to install Unity software and I assume that you have prior knowledge about the unity and C#.
Hardware Requirements
A computer (desktop or laptop) running Windows 10.
A Huawei phone (with the USB cable), which is used for debugging.
Software Requirements
Java JDK installation package.
Unity software installed.
Visual Studio/Code installed.
HMS Core (APK) 4.X or later.
Integration Preparations
1. Create a project in AppGallery Connect.
2. Create Unity project.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
3. Adding Huawei HMS AGC Services to project.
5. Generate a SHA-256 certificate fingerprint.
To generating SHA-256 certificate fingerprint use below command.
6. Configure the signing certificate fingerprint.
7. Download and save the configuration file.
Add the agconnect-services.json file following dir Assets > Plugins > Android
8. Add the following plugin and dependencies in LaucherTemplate
Code:
apply plugin: 'com.huawei.agconnect'
Code:
implementation 'com.huawei.agconnect:agconnect-core:1.4.1.300'
implementation 'com.huawei.hms:base:5.0.0.301'
implementation 'com.huawei.hms:hwid:5.0.3.301'
implementation 'com.huawei.hms:game:5.0.1.302'
implementation 'com.huawei.hms:push:4.0.1.300'
implementation 'com.huawei.hms:hianalytics:5.0.3.300'
9. Add the following dependencies in MainTemplate.
Code:
implementation 'com.huawei.agconnect:agconnect-core:1.4.1.300'
implementation 'com.huawei.hms:base:5.0.0.301'
implementation 'com.huawei.hms:hwid:5.0.3.301'
implementation 'com.huawei.hms:game:5.0.1.302'
implementation 'com.huawei.hms:hianalytics:5.0.3.300'
implementation 'com.huawei.hms:ads-lite:13.4.29.303'
implementation 'com.huawei.hms:ads-consent:3.4.30.301'
implementation 'com.huawei.hms:push:4.0.1.300'
implementation 'com.huawei.hms:location:5.0.0.301'
10. Add the following dependencies in MainTemplate.
repositories & class path in BaseProjectTemplate.
Code:
maven { url 'https://developer.huawei.com/repo/' }
Code:
classpath 'com.huawei.agconnect:agcp:1.2.1.301'
11. Add Achievement details in AGC > My apps
12. Add LeaderBoard details.
Continue reading..
Tips and Tricks
Add agconnect-services.json file without fail.
Add SHA-256 fingerprint without fail.
Add Achievements and LeaderBoad details before run.
Make sure dependencies added in build files.
Enable location and accept permission to read location.
Conclusion
We have learnt integration of HMS GameService Kit, Ads Kit,Location kit, Push Kit and Analytics kit in Unity. Error code while fetching Player extra information and Event Begin and end.
7006: The account has not been registered in Chinese mainland. In this case, perform bypass and no further action is required.
Thanks for reading, please do like and comment your queries or suggestions.
Read full article
References
Hms game services
HMS Ads Kit
HMS Analytics Kit
HMS Push Kit
Location Kit
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Introduction
In this article, we will learn how to integrate Huawei Analytics kit in Android application KnowMyBoard. Account Kit provides seamless login functionality to the app with large user base.
Huawei Analytics kit provides very easy and convenient way to add custom events, custom events can be used to meet personalized analysis requirements that cannot be met by automatically collected events or predefined events. Analytics Kit allows you to customize events and extend event parameters, or add personalized parameters for predefined events.
Supported Devices
Restrictions
Number of events: A maximum of 500 events are supported.
Number of event parameters: You can register a maximum of 25 parameters for each event, and a maximum of 500 event parameters for each project.
Development Overview
You need to install Android Studio IDE and I assume that you have prior knowledge of Android application development.
Hardware Requirements
A computer (desktop or laptop) running Windows 10.
Android phone (with the USB cable), which is used for debugging.
Software Requirements
Java JDK 1.8 or later.
Android Studio software or Visual Studio or Code installed.
HMS Core (APK) 4.X or later
Integration steps
Step 1. Huawei developer account and complete identity verification in Huawei developer website, refer to register Huawei ID.
Step 2. Create project in AppGallery Connect
Step 3. Adding HMS Core SDK
Let's start coding
How to Add Custom Event in AGC?
Login to AppGallery Connect Console, select projects and choose your project and navigate to Events
How to initialize Analytics Kit?
[/B]
public class MyApplication extends Application {
public static Activity myactivity;
static HiAnalyticsInstance instanceAnalytics;
@Override
public void onCreate() {
super.onCreate();
MLApplication.initialize(this);
//initialize Analytics Kit
instanceAnalytics = HiAnalytics.getInstance(this);
MLApplication.getInstance().setApiKey(Constants.API_KEY);
MapsInitializer.setApiKey(Constants.API_KEY);
}
public static HiAnalyticsInstance getAnalyticsInstance(){
return instanceAnalytics;
}
public static void setActivity(Activity activity) {
myactivity= activity;
}
public static Activity getActivity() {
return myactivity;
}
}
[B]
How to send Custom Events?
[/B][/B]
private void sendEvent(String eventName,String eventType) {
Bundle bundle = new Bundle();
bundle.putString(eventType,eventType);
bundle.putString( "event_time", getTime());
MyApplication.getAnalyticsInstance().onEvent(eventName, bundle);
}
[B][B]
Result
Tricks and Tips
Makes sure that agconnect-services.json file added.
Make sure required dependencies are added
Make sure that service is enabled in AGC
Enable data binding in gradle.build file
Enable debug mode to see events details in get App debugging hit this command in terminal
adb shell setprop debug.huawei.hms.analytics.app pkg_name
Conclusion
Finally, we have learnt how to integrate Huawei Analytics kit in Android application KnowMyBoard. You can check the desired result in the result section. You can also go through previous article part-5 here. Hoping Huawei Analytics kit capabilities are helpful to you as well, like this sample, you can make use as per your requirement.
Thank you so much for reading. I hope this article helps you to understand the integration of Huawei Analytics kit in Android application KnowMyBoard.
Reference
Huawei Analytics Kit — Training video
Checkout in forum