Intelligent Product Advisor for Shopping Applications by Huawei Awareness Kit

Murat Çakır
Huawei Developers
Published in
4 min readOct 7, 2020

Hello everyone,

In this article, we will talk about how to use the Huawei Awareness Kit feature to show intelligent product ads in an e-commerce application. Perhaps the most used apps and sites at these days are about e-commerce. We will look at the use of Awareness Kit from a different perspective. An e-commerce application always wants to show us products that will interest us. They use different features to do this. Usually the products we looked at before are indexed. But actually the products that will attract our attention are a reflection of what we do in our daily life. In addition, it determines the products that will attract our attention in the conditions of the region we live in. For example, if the region we live in is in winter, winter clothes should be recommended. As a behavior, it can recommend headphones or sports products if we often put headphones or walk or run. I think that is different and more intelligent than the ordinary methods used to recommend the product.

We talked about using the Awareness Kit. So what exactly is the Awareness Kit?
HUAWEI Awareness Kit provides your app with the ability to obtain contextual information including users’ current time, location, behavior, audio device status, ambient light, weather, and nearby beacons. Your app can gain insight into a user’s current situation more efficiently, making it possible to deliver a smarter, more considerate user experience.

Let’s do some coding then!

We will talk in detail about the cases that can be used in E-commerce applications while developing.

Before we start developing, we need to integrate HMS into your application. We can do this using the link below.

In the coding phase, we will run the Time Awareness feature with a button in AwarenessActivity. Before using the Awareness Kit features, we should not forget to get location and user activities permissions from the user.

Let’s create our AwarenessType model.

Let’s write a function named getAwarenessData() to be observed in AwarenessActivity that will work with awarenessType object in ViewModel. In this function, let’s call the getAwarenessCaptureData function, which is in the AwarenessCaptureDataSource, and observe to the return value.

We run the Time Awareness Kit and parse the response. Then we set the result to the AwarenessData model. The awarenessDataValue type is Any. Because we set each AwarenessKit result to this object. Then we send the data to the viewModel with return.

The data first returns to ViewModel. Then the function that observes that data in the activity runs. awarenessValueData object is of type Any. We set this object to the TimeAwarenessData model. We also create an enum model with the data we get from Huawei official documents.

Actually, we just call the Awareness Kit and parse the data. Now, let’s talk about how we can use the Awareness Kit in e-commerce application.

If you look carefully, we call the saveAwarenessData function in the getAwarenessCaptureData(3 in the previous code) function. (Line 18)
In this function, we save the data we get from Awareness Kit in local memory with sharedPreferences. You can save this data in a cloud database system or in sql lite. I save the data as a string.

So how can we map the data and recommend the right product to the user?
For this, let’s first create an enum model named ProductType. This model has some types of products. Then, using the Awareness Kit, we can check each char value of the data we saved in the local memory and find a compatible product recommendation. This part can completely change with your creativity. I used the time awareness kit feature in this article.

Let me give you extra examples for the Behavior and Weather Awareness Kit feature. Perhaps the most successful features for suggestions are Weather and Behavior features of Awareness Kit.

It is very important to show the right ad for e-commerce applications at these days. Another method that can be used for this is the Huawei Awareness Kit. I think that this idea is a case open to development.

Let me give a few screenshots of the application.

--

--