In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to quickly complete the client Demo development of Authorization Code mode". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Demo development preparation
1. Install Android Studio 3.5 and above
2. Install JDK 1.8 or above
3. Use Android SDK Platform 19 or above
4. Use Gradle 4.6or above
5. Register as a Huawei developer in Huawei developer Alliance. If you have already registered, please skip this step.
Running environment configuration
has previously tried demo development according to the official guidance of Huawei account, and found that the early steps of connecting to Huawei developer Alliance are a bit cumbersome, and various interfaces are switched back and forth. Later, it was found that HMS provides an IDE plug-in on Android Studio, which can help rapid integration. This article mainly introduces how to quickly create a Huawei account demo through this IDE plug-in.
If you want to manually follow the steps to create the demo of your account, you can check out this official guide: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/dev-process-0000001050443773
IDE plug-in installation
this tool called HMS Toolkit, later found that Huawei official introduction, you can go to their home page to learn about: https://developer.huawei.com/consumer/cn/huawei-toolkit/ installation plug-ins, directly in the Android Studio inside, click "File > Settings > Plugins", search "HMS" to find HMS Toolkit on it, click install and restart Android Studio.
Create an android project
Before develops an application, you have to have a local Android project, and the existing Android project is negligible. step 1 open the Android Studio software, click "File > New > New Project", select according to your own needs, I choose "Empty Activity" here, and click "Next".
step 2 enter the project name, package name, project storage location, project language and minimum SDK version in the "Configure Your Project" interface, and then click "Finish" to complete the project creation.
Configure AppGallery Connect
in order to access Huawei, we also need to create an application in AppGallery Connect and make some basic settings. Step 1 Log in to AppGallery Connect (https://developer.huawei.com/consumer/cn/service/josp/agc/index.html) using Huawei account. If you do not register, just follow the instructions on the page to complete the account registration, and then select "my Project".
Step 2 Click "add Project" on my project page.
Step 3 enter a name as the project name and click OK.
Step 4 after the project is successfully created, it will automatically go to the "Project Settings" page, where you will find "add Application" and click.
if you already have a project and already have an app, directly expand the application selection area at the top of the page and select "add App".
Step 5 fill in the application information on the "add Application" page, paying special attention to the platform and package name, especially the package name that is the same as the package name of the android project you created earlier.
Select platform: select "Android".
application package name: it needs to be consistent with the package name of the application you are developing.
After the configuration is completed, some of the later operations can be ignored, just go to the Android Studio operation, and the installed IDE plug-in can help set up.
Configure Huawei AGC and Huawei account for the project on Android Studio
step 1 in Android Studio, select "HMS > Configuration Wizard" in the menu bar. If you are not logged in to AppGallery Connect, this tool will automatically open the browser and prompt you to log in.
After logging in to step 2, you can select the team name, corresponding project module, Integrated Kits (select Account Kit) and certificate type in the Configuration Wizard interface, click "Generate" to generate the SHA256 certificate fingerprint, and then click "Next".
After selecting the team name and the corresponding project module, Toolkit automatically detects whether there is a corresponding application on the AGC. If an error is reported, click "Link" to AGC according to the interface to check whether the application has been created. If not, create a new application (this is the previous "configure AppGallery Connect" step), and then click "Retry".
's description of certificate types is as follows:
Use your certificate: directly use the certificate you created to generate the SHA256 certificate fingerprint, which is used when the application is published. For instructions on certificates, see Android Certificate signing (https://developer.android.com/studio/publish/app-signing#generate-key).
Use Android debug certificate: select the debug certificate that comes with Android to generate SHA256 certificate fingerprint. This method is only used for debugging scenarios. This is a Demo, and I chose this directly for simplicity.
can automatically generate the certificate fingerprint by clicking "Generate". If the generation fails, check whether the certificate information is correct, make sure that the certificate information matches the fingerprint, or generate the fingerprint manually according to the instructions for generating the certificate fingerprint, and then fill it into the fingerprint information box.
The plug-in automatically checks the environment configuration of the environment in which Account Kit is used, and I haven't encountered a failure yet. After all the check items are passed, directly click the "Go to coding assistant" button, you can go to the Account Kit page to select the interface to be called.
Log in to the account through Coding Assistant integrated Authorization Code mode
step 1 in Android Studio, select "HMS > Coding Assistant", and then click "Account Kit" in the Kit list.
step 2: mouse over the line "Signing In With an ID (Authorization Code)", drag and drop, and drag and drop the line to the code area.
After the mouse is released, the selection box for the new code snippet will pop up and click "OK" directly, you can see the relevant Activity file and xml layout file that will generate Authorization Code login, and AndroidManifest.xml, project build.gradle and module build.gradle all have some new information. What are the changes in the specific documents? see the login details below.
step 3 opens the "AndroiManifest.xml" file and replaces the Activity that applied the initial call with the Activity generated in step 2, so that our APP can actively call the newly added Activity.
this way, an account login Demo is completed.
The running and debugging of Demo can be viewed in your own device or in a remote real machine.
Compile, debug
Run using a remote real machine
Step 1 Select "HMS > Cloud Debugging" in the menu bar of Android Studio or click the icon below in the toolbar.
Step 2 remote real machine interface, you can filter the real machine to be debugged remotely according to the resolution and Android version.
There is a pit, the real machine in Shenzhen area does not know why, it cannot enter the "settings", which causes the Demo of the account to run and cannot pull up the login page. It is strongly recommended to use a real machine in a non-Shenzhen area for testing.
Step 3 Click (Run button) or (Debug button) in the menu bar to run or debug App on the remote real machine.
Step 4 enter the running project, click the "AUTHORIZATIONCODE MODE SIGNIN" button, and pull up the Huawei account login page, which is the Huawei account logged in through Authorization Code.
Run using a local real machine
runs or debugs App on the local real machine by clicking (Run button) or (Debug button) in the menu bar.
The running result of real machine is as follows:
This is the end of the content of "how to quickly complete Authorization Code mode client Demo development". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.