How To Transfer Google App On Huawei

February 24, 2021 Publish By : EXPERT APP DEVS 12 min read Viewed By : 896
Transfer Google App On Huawei
  • Huawei has lots of uses on its newly released Huawei Mobile Services (HMS), it’s very own suite of apps and offerings to update Google.
  • The prohibition on Google Mobile Services (GMS) as a part of the present-day US alternate regulations places key apps along with Chrome, Gmail, and Google Maps out of reach of the Chinese firm.
  • While Huawei says it's been slightly tormented by the ban on US community element supplies, way to its stock buildup, and the capacity to supply components via 1/3 countries, the GMS ban threatens its worldwide handset business.
  • The business enterprise unveiled Huawei Mobile Services (HMS) and an app marketplace primarily based totally on HMS, the App Gallery, at an occasion in Barcelona on Tuesday. It additionally introduced the Honor V30, the primary HMS-prepared handset.
  • GMS's absence isn't a large deal in China, which Google exited a decade ago, however glaringly it topics lots to non-Chinese consumers.

In this article, we will cover how to archive below components or features in Huawei.

1) Huawei Map

2) Huawei Notification

3) Huawei Crash Service

4) Huawei Analytics Kit

1) Huawei Map
 

integrate the Huawei Map in your Android Application

 

  • HMS Core Map SDK is fixed of APIs for map improvement in Android. The map statistics covers maximum international locations outside China and helps more than one language. The Map SDK makes use of the WGS eighty-four GPS coordinate system, that can meet maximum necessities of map improvement outdoor China. You can without difficulty upload map-associated capabilities to your Android app.
  • HUAWEI Map Kit gives an SDK for map development. It covers map statistics of greater than two hundred international locations and regions and helps dozens of languages. With this SDK, you may effortlessly combine map-primarily based totally features into your apps.
  • Displays buildings, roads, water systems, and Points of Interest (POIs) using Huawei map in Android.
  • Controls the interaction gestures and buttons on the map using Huawei map in Android.
  • Adds location markers, map layers, overlays, and various shapes. using the Huawei map in Android.

 

Follow the below steps for integrating the Huawei Map in your Android Application.

Step: 1

To use Map Kit, you should follow the subsequent preparations:

  • Create an app in AppGallery Connect and enable map kit.
  • Add the app bundle name.
  • Create an Android Studio project.
  • Generate signing certificates.
  • Generate a signing certificate fingerprint.
  • Configure the signing certificate fingerprint.
  • Add the AppGallery Connect plug-in and the Maven repository inside the project-level build.gradle file.
  • Configure the signature file in Android Studio.

Step 2:

Set Application environment:
 

  • Download agconnect-services.json file from AppGallery Connect.
  • Add agconnect-services.json to the app folder in your android project.
  • Add below dependency in app-level build.gradle

dependencies {
    implementation 'com.huawei.hms:maps:{version}'
}

Add apply plugin: 'com.huawei.agconnect' to the file header in app-level build.gradle.

Step : 3

Implement code for Huawei map integration.

Add below android permissions into Android Manifest xml file
 

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

 

Add below code in activity_main xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <com.huawei.hms.maps.MapView
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        map:cameraTargetLat="51"
        map:cameraTargetLng="10"
        map:cameraZoom="8.5"
        map:mapType="normal"
        map:uiCompass="true"
        map:uiZoomControls="true" />

</LinearLayout>

Follow the below code for MainActivity.java

package com.wz.android.mapdemo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.huawei.hms.maps.HuaweiMap;
import com.huawei.hms.maps.MapView;
import com.huawei.hms.maps.OnMapReadyCallback;

/**
* map activity entrance class
*/
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {

    private static final String TAG = "MapViewDemoActivity";
    //HUAWEI map
    private HuaweiMap hMap;

    private MapView mMapView;

    private static final String MAPVIEW_BUNDLE_KEY = "MapViewBundleKey";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //get mapview instance
        mMapView = findViewById(R.id.mapView);
        Bundle mapViewBundle = null;
        if (savedInstanceState != null) {
            mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
        }
        // please replace "Your API key" with api_key field value in
        // agconnect-services.json
        MapsInitializer.setApiKey("Your API key");
        mMapView.onCreate(mapViewBundle);
        //get map instance
        mMapView.getMapAsync(this);
    }

    @Override
    public void onMapReady(HuaweiMap map) {
        //get map instance in a callback method
        Log.d(TAG, "onMapReady: ");
        hMap = map;
    }
@Override
protected void onStart() {
    super.onStart();
    mMapView.onStart();
}

@Override
protected void onStop() {
    super.onStop();
    mMapView.onStop();
}

@Override
protected void onDestroy() {
    super.onDestroy();
    mMapView.onDestroy();
}

@Override
protected void onPause() {
    mMapView.onPause();
    super.onPause();
}

@Override
protected void onResume() {
    super.onResume();
    mMapView.onResume();
}
}

Step 4:

Install and run the application :

To install the developed app, double click on the install debug file in Android studio.

2) Huawei Notification

  • Support 230+ countries/regions worldwide.
  • Lets you immediately push 99% of your messages to consumer gadgets inside 10 minutes, even if your app isn't running in the background.
  • Provides the system-stage channel via which thousands of messages may be despatched per second and billions of messages per day.
  • Enables consumer gadgets to share receipts in actual time on your server after receiving your messages,
  • Precisely sends messages to precise audiences primarily based totally on tags and topics, in addition to helping scenario-based messaging.
  • Provides more than one textual content patterns, Inbox style, button style, and custom-designed style (along with the icon or ringtone). You can outline personalized patterns to draw users.
  • Enables you to carry out messaging in AppGallery Connect. Even if you do not have a server, you could function your app.
  • Adapts your messages to the language used on a user device under the idea that the messages had been configured in the language, enhancing operations efficiency.
  • Supports famous cross-platform mobile app development frameworks, like React Native, Cordova, Xamarin, and Flutter. You simply want to integrate the corresponding SDK plug-in bundle to develop an app so that the app can run on both iOS and Android.

Follow the below steps for integrating the Huawei push kit in your Android Application.

Step: 1

To use the Push Kit, you should follow the subsequent preparations

  • Create an app in AppGallery Connect.
  • Add the app bundle name.
  • Create an Android Studio project.
  • Generate signing certificates.
  • Generate a signing certificate fingerprint.
  • Configure the signing certificate fingerprint.
  • Add the AppGallery Connect plug-in and the Maven repository inside the project-level build.gradle file.
  • Configure the signature file in Android Studio.

Step 2:

Set Application environment:

  • Download agconnect-services.json file from AppGallery Connect.
  • Add agconnect-services.json to the app folder in your android project.
  • Add below dependency in app-level build.gradle.

dependencies {
    implementation 'com.huawei.hms:push:5.0.0.300'
}

 

  •   Declare service and metadata in  Application Tag in Manifest file like below.

<application
<service
    android:name=".MyPushService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
    </intent-filter>
</service>
    <meta-data
        android:name="push_kit_auto_init_enabled"
        android:value="true" />

</application>

Step 3

Create a push service class

 

public class MyPushService extends HmsMessageService {

    private static final String TAG = "PushDemoLog";
    @Override
    public void onNewToken(String token) {
        super.onNewToken(token);
        Log.i(TAG, "receive token:" + token);
        sendTokenToDisplay(token);
    }

    private void sendTokenToDisplay(String token) {

        Intent intent = new Intent("com.huawei.push.codelab.ON_NEW_TOKEN");
        intent.putExtra("token", token);
        sendBroadcast(intent);
    }
}

 

 

  • The token is received by using the onNewToken override method.

Step 4 :
Implement a Broadcast receiver for getting token
 

public class MainActivity extends AppCompatActivity {
    private TextView tvToken;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tvToken = findViewById(R.id.tv_log);

        MyReceiver receiver = new MyReceiver();
        IntentFilter filter=new IntentFilter();
        filter.addAction("com.huawei.codelabpush.ON_NEW_TOKEN");
        MainActivity.this.registerReceiver(receiver,filter);
    }

    public class MyReceiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            if ("com.huawei.codelabpush.ON_NEW_TOKEN".equals(intent.getAction())) {
                String token = intent.getStringExtra("token");
                tvToken.setText(token);
            }
        }
    }
}

 


 

  • Run the Application.
     
  • For test push notification refer to the sending message.

 

3) Huawei Crash Service

 

integrate the Huawei crash service in your Android Application

 

  • The Crash service of AppGallery Connect is a light-weight crash evaluation service, in which Huawei offers a Crash SDK that can be fast integrated into your app, without the need for coding. 

  • The SDK integrated into your app can mechanically gather crash records and document the records to AppGallery Connect when your app crashes, assisting you to recognize the version quality of your app, quickly find the reasons for crashes and examine the impact scope of crashes. 

  • In this article, we will create an app that can integrate the Crash service and manually trigger a crash to test the Crash service.


 

Follow the below steps for integrating the Huawei crash service in your Android Application.

Step: 1

To use crash service, you should follow the subsequent preparations:

  • Create an app in AppGallery Connect.
  • Add the app bundle name.
  • Create an Android Studio project.
  • Add the AppGallery Connect plug-in and the Maven repository inside the project-level build.gradle file.
  • Sync the project.

Step 2:

Set Application environment:

 

  • Download agconnect-services.json file from AppGallery Connect.
  • Add agconnect-services.json to the app folder in your android project.
  • Add below dependency in app-level build.gradle and sync project.

 

dependencies {
  implementation 'com.huawei.hms:hianalytics:5.0.5.300'
  implementation 'com.huawei.agconnect:agconnect-crash:1.4.2.300''
}
 

 

Step 3

Check crashes and exception:

  • First Sign in to AppGallery Connect and click My projects and click on your project.
  • Tap on Add filter and select Exception in User attribute > Event type. This filter is not selected upon your first access by default. Tap on the Statistics tab and select Last hour to view crash and exception statistics of your app.

4) Huawei Analytics Kit

 

Huawei Analytics Kit

 

  • HUAWEI Analytics Kit pre defines rich analytics models to help you clearly understand user behavior and gain in-depth insights into users, products, and content. As such, you can carry out data-driven operations and make informed decisions about app marketing and product optimization.
  • Analytics Kit implements the following functions using data collected from apps:
  • Provides data collection and reporting APIs for collection and reporting of custom events.
  • Sets up to 25 user attributes.
  • Supports automatic event collection and session calculation as well as predefined event IDs and parameters

Follow the below steps for integrating the Huawei push kit in your Android Application.
 

Step: 1

To use the Push Kit, you should follow the subsequent preparations:

  • Create an app in AppGallery Connect.
  • Add the app bundle name.
  • Create an Android Studio project.
  • Generate signing certificates.
  • Generate a signing certificate fingerprint.
  • Configure the signing certificate fingerprint.
  • Add the AppGallery Connect plug-in and the Maven repository inside the project-level build.gradle file.
  • Configure the signature file in Android Studio.

Step 2:

Set Application environment:

  • Sign in to AppGallery Connect and select My projects.
  • Click the app for which you need to enable Analytics Kit.
  • Select any menu under HUAWEI Analytics and click Enable Analytics service.
  • Download the configuration file name as agconnect-services.json.
  • Add agconnect-services.json to the app folder in your android project.
  • Add below dependency in app-level build.gradle and sync project.

 

dependencies {
  classpath  'com.huawei.agconnect:agcp:1.4.1.300'
}
repositories {
    maven {url 'https://developer.huawei.com/repo/'}
}

 

  • Add the AppGallery Connect plug-in dependency in build.gradle. 

 

apply plugin: 'com.huawei.hms.agconnect'

Step 3 :
Check Analytics

  • Login to AppGallery Connect and select My projects.
  • Select the application which you want to manage.
  • You can check analytics with this flow: HUAWEI Analytics > Overview > Real-time monitoring.
  • Check the data. For more details, please refer to this  HUAWEI Analytics Kit Operation Guide.

Reference :

https://developer.huawei.com/

Need a consultation?

Drop us a line! We are here to answer your questions 24/7.