目录

1. Scenario

A user launches the game by tapping the app icon. At that moment, the app background initializes HMS SDK. 

2. Service Process

  1. A user launches the game by tapping the game app icon on a mobile device.

  2. The game app executes its startup program and loads the required resources. The startup program is created by the developer.

  3. In the startup program, the game app calls JosApps.getJosAppsClient method to obtain the JosAppsClient instance.

  4. HMS SDK returns the current JosAppsClient instance of the game app.

  5. The app calls the JosAppsClient.init method to initialize the game.

  6. After successful startup, the game app displays the home page and checks for updates. For details about the app upgrade process, see Updating the game.

3. Notes

4. Development Procedures

The key steps for launching the game are as follows:

1. Add the following code to the onCreate method of the Application to register the callback listening function of the activity.

  1. public class MyApplication extends Application{
  2.    @Override
  3.    public void onCreate(){
  4.        super.onCreate();
  5.        HuaweiMobileServicesUtil.setApplication(this);
  6.    }
  7. }
Note:
Before compilation, ensure that the name of the Application class, for example, android:name=".MyApplication" has been configured on the application node in the app's manifest file.

2. Call JosApps.getJosAppsClient to initialize the JosAppsClient object and JosAppsClient.init to initialize the game.

  1. private void init() {
  2.    JosAppsClient appsClient = JosApps.getJosAppsClient(this, null);
  3.    appsClient.init();
  4.    Log.i(TAG, "init success");
  5. }

No result will display after init is called, and no action is required from your app.