How to add a card to huawei

Embed cards from Huawei in the Android app

card, huawei

In previous articles, we created a developer account to use Huawei Mobile Services and prepared the project for their use. Then we used analytics from Huawei instead of Google’s analogue. They did the same thing with geolocation definition. In this article we will use Huawei maps instead of Google maps.

  • Creating a developer account, plugging in dependencies, preparing code for implementation. click
  • Embed Huawei Analytics. click
  • Use geolocation from Huawei. youk
  • Huawei maps. Use instead of Google maps for AppGallery. ← you’re there

What’s the difficulty

Unfortunately, maps will not work as easily as analytics and geolocation. Which is not surprising, t.к. it is a much more complex system in itself. And very often in applications, maps and their interaction are customizable. For example, displaying markers, clustering them. So there will be a lot of code, t.к. you need to put all this behind the scenes, keeping in mind some differences in the map APIs of the different implementations.

Create an abstraction on top of the map

We have to use different classes in the markup to display the map. for google maps and com.huawei.hms.maps.MapView for Huawei. Let’s create our own abstract view inherited from FrameLayout and use it to load a concrete MapView implementation with different flavors. Also create in our abstract view all of the methods we need to call on specific implementations. Also we need a method of getting the object of the map itself. And methods for direct implementation of MapView from Google and Huawei and casting attributes to the maps from the markup. Here we have such a class:

For the attributes in the markup to work, of course, we need to define them. Add to res/values/attrs.xml this:

This will allow us directly in the markup, using our abstract map to pass the map type and whether we need a light mode for it. It will look something like this in the markup (the MapViewImpl implementation will be shown later):

As you can see in the code of our abstract class MapView. SomeMap in the getMapAsync method is used there. So let’s show you at once what other common classes and interfaces we’ll need before we move on to using the various map implementations.

SomeMap. the main class for working with maps. In its overrides we will throw method calls to show markers, assign event listeners and display options and to move the camera around the map:

SomeCameraUpdate. we need to move the camera on the map to some point or area.

SomeLatLngBounds. a class for describing the area on the map where you can move the camera.

SomeMarkerOptions. for specifying the icon and the position of the marker.

SomeClusterItem. for the marker for clustering.

SelectableMarkerRenderer is needed to be able to select markers when clicked, changing their icon and saving the selected marker.

We also want to be able to configure the appearance of the marker in a sophisticated way. For example by generating an icon for it from the markup. To do this, let’s copy a class from the google library. IconGenerator :

Create an implementation of our abstract map

Finally we redefine the abstract classes that we created.

We also add the resolution you need for the maps to the manifest. To do this, create another manifest file ( AndroidManifest.xml ) in the src/huawei/ folder with this content:

This is how the implementation of maps for Google will look like. We add the MapViewImpl class to the folder src/google/kotlin/com/example :

And in the folder src/huawei/kotlin/com/example the similar class MapViewImpl but using maps from Huawei:

Here we should pay attention to 3 points:

  • We create the map view programmatically, rather than loading it from the markup.к. This is the only way to pass options (light mode, map type etc) into it.
  • Redefined onTouchEvent and dispatchTouchEvent. with a roll call to mapView. without this, maps won’t respond to taps.
  • The implementation for Huawei has detected a crash when suspending the card in the onPause method. Had to wrap in try-catch. I hope this will be corrected in the library update)
Read more:  How to Snap a Card to a Phone Over the Internet

Implementing additional abstractions

And now for the hardest part. We had quite a lot of code in our application to display, customize and handle clicking on markers and marker clusters. When they started trying to abstract it all away, there were complications. Almost immediately it turned out that although Huawei maps have clustering, it is not fully analogous in functionality to the clustering from Google. For example it is impossible to influence the appearance of a cluster and to process clicks on it. Also in Huawei maps, the appearance of individual markers (and their event handling) works the same way as markers that should be clustered. But it’s different in google-maps for clustering markers. a separate processing of events, a separate way to customize appearance and in general it’s all done in a separate library. As a result, we had to think how to rewrite the code in order to retain the Google maps functionality and make Huawei maps work.

So, we ended up with the following option: we create a method for displaying the set of tokens that should be clustered, pass the event listeners we need into it, and return a lambda for the token selection functionality. Here’s an implementation of SomeMap for google maps:

The hardest part, as already mentioned, is in the addMarkers method. It uses ClusterManager and ClusterRenderer. analog which does not exist in Huawei cards. In addition, these classes require that the objects from which we will create our markers for clustering, must implement the ClusterItem interface. The analogue of which also does not have Huawei. In the end I had to wiggle around and combine inheritance with encapsulation. The data classes in the project will implement our SomeClusterItem interface. and google interface ClusterItem will implement the wrapper over the class with the marker data. Here’s one:

As a result, we will use a library-independent interface on the outside, and inside the google maps we will wrap its instances into a class implementing the ClusterItem from the google library. For details, see the addMarkers implementation above.

To make it all work, we only need to add these classes:

The implementation for Huawei will be easier. we don’t have to bother with wrapping SomeClusterItem. Here are all the classes we need to put in src/huawei/kotlin/com/example :

That’s where we’ve finished implementing our abstractions. It remains to show how this will be used in the code. It is important to keep in mind that unlike analytics and geolocation, which work on any device with Huawei Mobile Services installed, maps will only work on devices from Huawei.

Using our abstract map

So, in the markup we add MapViewImpl. as shown above and move on to the code. First, we need to get a map object from our MapView:

When we get it, we will draw markers on it with our abstraction. And also, when pressed, highlight them and display a message. And also to handle clicking on the cluster. At the same time, as planned, we do not depend on the implementation of the maps:

Some of the code is, understandably, omitted for brevity. You can find the full example on GitHub.

And here’s how the maps of different implementations look like (first Huawei, then Google):

The bottom line with maps is that maps are much more complex than location and analytics. Especially if there are tokens and clustering. Although it could be worse, of course, if the API for working with maps was more different. So we can say thank you to the Huawei team for facilitating support for their implementation cards.

The mobile app market is changing. Yesterday seemingly unshakable monopolies of Google and Apple finally noticed not only by developers who suffered from them (the most famous ones are Telegram, Microsoft, Epic Games), but also by the state structures of EC and US level. Hopefully, against this background, a healthy competitive environment will finally emerge, at least for Android. Huawei’s work in this area is encouraging. it is clear that people are trying to make life as easy as possible for developers. After experience with the tech. I had a problem with GooglePlay, where you get answers from robots (and they ban you, too) at Huawei you get answers from people. Not only that. when I had an issue with their app store. I was able to just call a live person from Moscow and quickly solve the problem.

In general, if you want to expand your audience and get quality in the process. go to Huawei. The more developers there are, the better the chance that something will change in GooglePlay for the better. And everyone will benefit.

Read more:  How To Set Up Keyboard On Huawei

All the code that is in this series of articles you can see in the repository on GitHub. Here’s the link.

How to insert a memory card into a Huawei tablet

The instructions for installing the drive are similar to a smartphone. In order to insert a memory card in Honor and Huawei follow these steps:

As soon as you complete the tasks, the phone will indicate that there is a new object. After this window is displayed, you can continue with the settings. You can set the path to save the gadgets. Or to free up gadget memory, transfer some files to the drive. Using explorer you can see the information about internal and external storages.

How to set up NFC on your Honor and Huawei phone

To make NFC payment available on the phone, it has to be connected and properly configured. A three-step setup guide will help with this question:

Step 1: how to turn on NFC

The first way is easier and faster. To activate NFC, just swipe down at the top of the screen to bring up the notification panel. After that it is necessary to press on the NFC icon, setting it in an active mode. This will be indicated by the change of its color from gray to turquoise.

The second method is a little more complicated, as it requires you to do more steps:

  • Open the settings of your phone.
  • Select “Connecting device”
  • Then the item “NFC”, where you need to move the slider to the right position.
  • There are no selected apps in the “Default payment app” item.

This completes the first step, move on to the second.

Step 2: install Google Pay

At this stage you need to download and install the Google Pay application on your phone. Instructions:

  • Go to Play Market;
  • Type “Google Pay” in the search bar and select the first application from the list;
  • Press “Install” and wait until the process is completed;
  • then go back to the settings item “Default payment application”, where you should see the Google Pay application.

Step 2 is finished, go to step 3.

Step 3: add a bank card for payment

Linking a bank card to a Huawei smartphone happens in the Google Pay app. This is how it is done:

  • Open application.
  • Press “Start”, then “Add card”.
  • Scan the card or press “Enter data manually”.
  • Fill in the required fields and press “Continue”.
  • Read the terms of use and if you are satisfied, click “Accept”.
  • Confirm the card data by pressing “Continue”.
  • Enter the PIN code received in the SMS message to confirm the card tethering.

At this stage the step is finished. Now you can pay for purchases simply by touching the terminal with your phone.

How Huawei Pay works

I think we should start with the description of Huawei Pay. As well as Apple Pay or Samsung Pay, the branded service of the Chinese company works through NFC and from the technical point of view is arranged in the same way. The service encrypts the data of the bank card, substituting it with the number of the virtual card, which it creates at the moment of binding. This protects the original card, and neither the seller, nor Huawei, nor the acquiring bank, which operates the payment terminal in the store and processes the transaction, can find out its number.

Payments via Huawei Wallet

In Huawei Wallet, purchases and online payments are made through Huawei Pay. For users, it increases transaction security: the service does not use the number of the bank card, but instead transmits the device card number or token. This number is assigned to each added bank card and differs on different devices. Thanks to this, bank card numbers are not transmitted to the merchant and are stored only on the devices, not on Huawei Pay servers. In addition, Huawei Pay does not store transaction information, which can be linked to the payer.

To make a payment, the user does not need to unlock the device, and contactless payment is possible even without connecting to the Internet. Huawei Pay uses SE hardware encryption technology and requires to verify every transaction regardless of the amount. Any bank that issues UnionPay cards can work with Huawei Pay. Gazprombank, Rosselkhozbank and Vostochniy Bank are already working with it in Russia. In the next year we will finalize the SDK and add the payment via Huawei Pay to our web services.

Another useful function of Huawei Pay is the ability to accept payments using QR codes. This functionality turns smartphone into POS-terminal: it allows to get payment for purchases using QR-code. To start accepting payments, a legal entity must register with the app.

Read more:  How to set the time on a Huawei phone

HUAWEI smartphones have a new contactless payment method in Sberbank

HUAWEI and Sberbank presented the new function SberPay, which is already available in the branded application “Sberbank Online”, available in HUAWEI AppGallery. Using SberPay the owners of HUAWEI smartphones can make contactless payment and top up at ATMs, using the NFC module.

The new functionality is available to Russian Sberbank users starting July 9, 2020. SberPay is a new contactless payment method for users of Sberbank Online mobile application. This service allows you to pay for purchases using a smartphone equipped with an NFC module. To use the service, Sberbank clients don’t need to install a special application on their smartphones and enter their card number, because SberPay is a part of Sberbank Online app.

In order to make contactless payments, you simply need to connect your card to the SberPay service on a special page within the app. After that he will be able to make contactless purchases, withdraw cash and top up cards from NFC-capable ATMs. To ensure a high level of privacy each transaction will be confirmed by scanning the fingerprint of the device owner or entering a digital code.

“The launch of SberPay is an important step in implementing a whole system of intuitive and secure payments. Our partnership with HUAWEI will allow Sberbank customers, owners of HUAWEI smartphones, to get access to convenient payment solutions that will provide maximum comfort in use of financial services both online and offline”. Svetlana Kirsanova, Deputy Chairman of the Management Board, Head of Retail Business at Sberbank.

SberPay service is currently available to owners of HUAWEI smartphones, who use Sberbank Visa cards. In the near future the service will also be available for other payment systems. Huawei users can download the “Sberbank Online” application from the official AppGallery, which ranks third in the world by number of applications and audience.

What is Huawei Pay and how to use it?

The ability to pay for purchases through the phone is a convenient feature that some Huawei models are equipped with. From this article you will learn how to set up payment with your Huawei phone.

#HMSTips: How to integrate with HUAWEI Wallet Kit

Let’s say you came to the store. You have filled up your groceries, stood in a long queue and the cashier asks for the last item, when suddenly you discover that you left your wallet at home. It’s a sense of wasted time Let’s leave it in the past and learn how to pay by phone.

There is NFC technology (short-range wireless communication), once set up, you can use your smartphone as a card. You might be in some doubt: Is it safe?? Yes. And here’s why:

NFC works only a few centimeters away. No one but the owner of the phone can use the service.

If you made sure that the NFC chip is present in your device, proceed to the actual procedure of setting up the payment. It has to be done once, and then you only have to confirm the withdrawal. The algorithm is as follows:

If you still have questions or complaints. Tell us

  • Move NFC sensor to active position;
  • opening Honor Pay;
  • You create an account;
  • You add your card and personal information to it;
  • Pass the identification through the phone number;
  • the software is ready to use.

If you are convinced of the availability, the next task is to set up NFC on Honor and Huawei. If you’re doing it for the first time, follow the order of the instructions.

turn on NFC on your smartphone

Enable NFC on your Honor and Huawei phone. simply. Go to general settings, select the item and move the slider next to it to the active position.

Setting up Google Pay

Google Pay virtual wallet can be downloaded to your device from the Play Store. This software is free, and tamper-proof. Therefore, provide payment card information there, go through authorization and save passwords is completely safe.

adding a card to NFC on Honor/Huawei

When you have already installed and opened Google Pay, add your payment cards there. The developers do not limit you in their number. On the main screen, click on the icon “Add” or “”. Then in the appropriate fields, enter details, expiration date, name and surname of the holder, individual CVV-number. Confirm your identity by verifying your phone number.