FORUMS

Huawei Share Kit Facilitates to Acquire Skill in Enforcement - Part 1

107 posts
Thanks Meter: 10
 
By Freemind R, Official Huawei Rep on 18th June 2020, 04:30 AM
Post Reply Email Thread
More articles like this, you can visit HUAWEI Developer Forum and Medium.


https://img.xda-cdn.com/1VML4RTNvfWgHRoDEujFWXktTLA=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060136.17559478831923220536215973422938%3A50510618025057%3A2800%3A6C996E276C70FD1756AE12972E525ECDB7C51531653C065518FB8599C84A4046.jpg

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.

https://img.xda-cdn.com/ZC7iU-lU7nQheOh5oj1kWq40iCo=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060253.13276759665206853245701873972582%3A50510618025057%3A2800%3A649125BB2A38530EF3D7983B9F30CFF0CC09EA283ED614784CFDECE975E31D4D.gif

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:

https://img.xda-cdn.com/MqDV1DU9yVftx2JVfmODshOs9n0=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060359.86733565144052717277116901626963%3A50510618025057%3A2800%3A7926342475C7CD6F26686BB14623DA39A194EB04B90F63E7793A9B9B6B9B99AB.jpg

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.

https://img.xda-cdn.com/UKEC3EOkr68MxGJ7LtGTMmP44zM=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060426.86476431151266220583898116296582%3A50510618025057%3A2800%3A30F34BDB428BDD755291D8F53AF3A6F0CE0AD1F23890DC2D31F3652224E8D429.png

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:

https://img.xda-cdn.com/vUFfLibGKphY5bmXNDgwalObNWk=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060500.56672168401160679144408537229135%3A50510618025057%3A2800%3A8DA63BC131C35162C3B5863544D5F183DD419C5A5B34B164C43B1251F29B69B3.png

2. Enter the file name and project location and click Finish:

https://img.xda-cdn.com/k-91DLX_lFhDMpIiBoNRIcy-Hos=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060515.18241464003226074088539573015624%3A50510618025057%3A2800%3A1EA39299DB4CCD154C7E1D57E4BFAA5D1B851FC80F621DBF2B2C2A82B5098EDD.png

3. Add Share SDK in the project:

https://img.xda-cdn.com/lrwjj97zd9uoa23K6m-Sm7nQv0Q=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060537.58083646521586297108663601784319%3A50510618025057%3A2800%3AFC40850CE5DCE5BE3835BE89FB154F4D8EE84E15A657321CC232B8FAC262C73D.png

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/consume...rt/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):

https://img.xda-cdn.com/C9FPlcQnTGBzVtqxDq8rhcB3at0=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060859.36711468348519386917658415497866%3A50510618025057%3A2800%3AC82012211EC612CDE29D7A7F5CD4016BA72003DE1FD65AFB62D98A2FA285F0A6.gif

https://img.xda-cdn.com/dxppLoRWt4DUp81jqqj9JzoD2nE=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610060950.26238476688476791442444861983727%3A50510618025057%3A2800%3A0BF8B3606E244516DDBE4655D18C0BF131341B6AB5F6BA563DACD2AB0BCCE68A.gif

https://img.xda-cdn.com/D7xhmB0bhC7IfGDtQE678g-EAcc=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610061107.78337866955906157613763559605502%3A50510618025057%3A2800%3A38C93A9340C7A31AAB0D430520805CDABABA0294388C4FFB9BCAC696D064773B.gif

Huawei device (Receiver):

https://img.xda-cdn.com/qTH4_FZ5pWg6s_hsficsTOs6CM4=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610061238.79225434580714349935517331734317%3A50510618025057%3A2800%3A674BCC4260D245F4DFDA27CDEC9FACB3426D084310386B20E81188ED8E5ECD5D.gif

https://img.xda-cdn.com/GsnQHLKjKJMJc2oUdo04iYld6Jw=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610061238.69594597845046422332490239442843%3A50510618025057%3A2800%3AF7EA2A6234E62A05DB9BAA3913E33E4F140B4FEF1EC5860724E7CAF66FE19E7E.gif

https://img.xda-cdn.com/Z96IHO6vGawderjqyyy1wx7MiU8=/https%3A%2F%2Fcommunityfile-dre.op.hicloud.com%2FFileServer%2FgetFile%2Fcmtybbs%2F001%2F768%2F541%2F2640091000001768541.20200610061238.06531090303532743198258151392412%3A50510618025057%3A2800%3A1CC8BBAD71B39EAD2A0335CB3DDE5BAA8EBFED85312BB3B4BC0D368987D89512.gif

If you have any doubts or queries. Please leave your valuable comment in the comment and ask your question in HUAWEI Developer Forum.
Post Reply Subscribe to Thread

Tags
huawei share kit

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes