├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── app ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ ├── app_loading_dialog.xml │ │ │ ├── activity_main.xml │ │ │ └── activity_registration.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ └── com │ │ │ └── huawei │ │ │ └── codelab │ │ │ └── dcidemo │ │ │ ├── push │ │ │ ├── HwPushMsgService.java │ │ │ └── HmsPushHelper.java │ │ │ ├── dialog │ │ │ └── AppLoadingDialog.java │ │ │ ├── DciDemoApplication.java │ │ │ ├── ErrorCode.java │ │ │ ├── view │ │ │ ├── BaseActivity.java │ │ │ ├── MainActivity.java │ │ │ └── RegistrationActivity.java │ │ │ └── utils │ │ │ ├── DataUtils.java │ │ │ └── HmsLoginUtils.java │ │ └── AndroidManifest.xml ├── .gitignore ├── proguard-rules.pro └── build.gradle ├── .gitignore ├── gradle.properties ├── README_ZH.md ├── README.md └── LICENSE /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HMS-Core/hms-DCI-demo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 01 17:31:35 CST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #007DFF 4 | #007DFF 5 | #007DFF 6 | #ffffff 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | /.idea 16 | /.gradle 17 | /app/release 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_loading_dialog.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | build/ 16 | captures/ 17 | 18 | # Local configuration file (sdk path, etc) 19 | local.properties 20 | develop.properties 21 | 22 | # Windows thumbnail db 23 | Thumbs.db 24 | 25 | # OSX files 26 | .DS_Store 27 | 28 | # Eclipse project files 29 | .classpath 30 | .project 31 | 32 | # Android Studio 33 | *.iml 34 | .idea 35 | 36 | #sign file 37 | *.jks 38 | 39 | # Local IDEA workspace 40 | .idea/workspace.xml 41 | 42 | # Gradle cache 43 | .gradle 44 | #NDK 45 | obj/ -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -ignorewarnings 23 | -keepattributes *Annotation* 24 | -keepattributes Exceptions 25 | -keepattributes InnerClasses 26 | -keepattributes Signature 27 | -keepattributes SourceFile,LineNumberTable 28 | -keep class com.huawei.hianalytics.**{*;} 29 | -keep class com.huawei.updatesdk.**{*;} 30 | -keep class com.huawei.hms.**{*;} -------------------------------------------------------------------------------- /app/src/main/java/com/huawei/codelab/dcidemo/push/HwPushMsgService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021. Huawei Technologies Co., Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.huawei.codelab.dcidemo.push; 18 | 19 | import android.os.Bundle; 20 | import android.text.TextUtils; 21 | 22 | import com.huawei.hms.push.HmsMessageService; 23 | 24 | /** 25 | * HMS Push Service class. 26 | * 27 | * @since 2021-06-02 28 | */ 29 | public class HwPushMsgService extends HmsMessageService { 30 | @Override 31 | public void onNewToken(String token, Bundle bundle) { 32 | if (!TextUtils.isEmpty(token)) { 33 | HmsPushHelper.setPushToken(token); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/huawei/codelab/dcidemo/dialog/AppLoadingDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021. Huawei Technologies Co., Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.huawei.codelab.dcidemo.dialog; 18 | 19 | import android.app.Dialog; 20 | import android.content.Context; 21 | import android.os.Bundle; 22 | import android.view.Window; 23 | 24 | import androidx.annotation.NonNull; 25 | 26 | import com.huawei.codelab.dcidemo.R; 27 | 28 | /** 29 | * Loading Dialog class. 30 | * 31 | * @since 2021-06-02 32 | */ 33 | public class AppLoadingDialog extends Dialog { 34 | public AppLoadingDialog(@NonNull Context context) { 35 | super(context); 36 | } 37 | 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | Window window = getWindow(); 42 | window.setBackgroundDrawableResource(android.R.color.transparent); 43 | setContentView(R.layout.app_loading_dialog); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/huawei/codelab/dcidemo/DciDemoApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021. Huawei Technologies Co., Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.huawei.codelab.dcidemo; 18 | 19 | import android.app.Application; 20 | 21 | import com.huawei.hms.dci.function.HwDciPublicClient; 22 | 23 | 24 | /** 25 | * DciDemoApplication class. 26 | * 27 | * @since 2021-06-02 28 | */ 29 | public class DciDemoApplication extends Application { 30 | private static Application sApplication; 31 | 32 | @Override 33 | public void onCreate() { 34 | super.onCreate(); 35 | setInstance(this); 36 | // Init DCI Kit 37 | HwDciPublicClient.initApplication(this); 38 | } 39 | 40 | private static void setInstance(DciDemoApplication application) { 41 | sApplication = application; 42 | } 43 | 44 | /** 45 | * Get application Instance. 46 | * 47 | * @return Application 48 | */ 49 | public static Application getInstance() { 50 | return sApplication; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/huawei/codelab/dcidemo/ErrorCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021. Huawei Technologies Co., Ltd. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.huawei.codelab.dcidemo; 18 | 19 | /** 20 | * DCI Kit Error code class. 21 | * 22 | * @since 2021-06-02 23 | */ 24 | public class ErrorCode { 25 | /** 26 | * DCI copyRight account register failed. 27 | */ 28 | public static final int NOT_REGISTER = 50000007; 29 | 30 | /** 31 | * Get DCI Account Information Success. 32 | */ 33 | public static final int GET_DCI_ACCOUNT_SUCCESS_CODE = 200; 34 | 35 | /** 36 | * Real-Name Authentication Failure Caused by Forcible Exit. 37 | */ 38 | public static final int REAL_NAME_FAIL_AS_FORCIBLE_EXIT = 10001001; 39 | 40 | /** 41 | * Hms token or openId is null. 42 | */ 43 | public static final int REAL_NAME_FAIL_AS_TOKEN_OR_OPENID_NULL = 10001002; 44 | 45 | /** 46 | * Hms token or openId Unavailable. 47 | */ 48 | public static final int HW_TOKEN_OR_UID_NOT_USED = 10001003; 49 | } 50 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.huawei.agconnect' 3 | android { 4 | def APP_ID = "\"xxx\"" 5 | compileSdkVersion 29 6 | buildToolsVersion "29.0.3" 7 | 8 | defaultConfig { 9 | applicationId "com.huawei.codelab.dcidemo" 10 | minSdkVersion 24 11 | targetSdkVersion 29 12 | versionCode 1 13 | versionName "1.0" 14 | buildConfigField("String", "APPID", "${APP_ID}") 15 | } 16 | signingConfigs { 17 | release { 18 | keyAlias "xxx" 19 | keyPassword "xxx" 20 | storePassword "xxx" 21 | storeFile file("xxx.xxx") 22 | } 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled true 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | signingConfig signingConfigs.release 30 | } 31 | debug { 32 | debuggable true 33 | minifyEnabled false 34 | zipAlignEnabled false 35 | shrinkResources false 36 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 37 | signingConfig signingConfigs.release 38 | } 39 | } 40 | 41 | compileOptions { 42 | sourceCompatibility JavaVersion.VERSION_1_8 43 | targetCompatibility JavaVersion.VERSION_1_8 44 | } 45 | } 46 | 47 | dependencies { 48 | implementation fileTree(dir: "libs", include: ["*.jar"]) 49 | implementation 'androidx.appcompat:appcompat:1.2.0' 50 | implementation 'com.huawei.hms:dci:3.0.2.301' 51 | implementation 'com.huawei.hms:push:6.1.0.300' 52 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |