HUAWEI Location Kit Scenario Description - Huawei Developers

1. Development Scenario
Location update
If your app needs to request the device location continuously, you can apply for the location permission for your app, call the requestLocationUpdates() API of Location Kit, set different request parameters (in LocationRequest), and specify a location mode as needed. To cancel location information callback, call the removeLocationUpdates() API.
Location semantics
If your app needs to obtain both the location information and its address information, you can set isNeedAddress in LocationRequest to true, specify a language and country code, and then call the requestLocationUpdates() API.
Activity identification
If your app needs to obtain the activity status of the user's device (for example, walking, running, or bicycling) or your app needs to detect activity status change of a user, you can apply for the activity identification permission for your app and call the createActivityIdentificationUpdates() API. To cancel activity identification update, call the deleteActivityIdentificationUpdates() API. If you want to detect user activity status change, call the createActivityConversionUpdates() API to listen on activity status changes of the current device. To cancel listening on activity status changes, call the deleteActivityConversionUpdates() API.
Geofence
If you are interested in a place, you can call the createGeofenceList() API to create a geofence based on the place. Then, Location Kit can sense the distance between the current device location and the geofence. When the device enters the geofence, a notification will be sent to your app. In addition, Location Kit can detect the duration during which the device stays in the geofence, and send a notification to your app if the duration reaches a specified value.
2. Development Process
The following figure shows the overall development process. The detailed development procedures are described in the following sections. If you have an app with third-party mobile services integrated, you can use HMS Convertor to automatically convert APIs of the third-party mobile services into HMS-based APIs, achieving quick integration of HMS services. To learn more about HMS Convertor, click here.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}

Related

PeakLens on HMS vs GMS

PeakLens on HMS vs GMS
PeakLens is an app that lets you explore mountains and peaks using AR. By pointing your camera at a mountain, you'll be able to learn more details about it. It's a good tool for anyone who loves to explore the outdoors and go mountain climbing. PeakLens uses artificial intelligence to estimate the position of nearby peaks. It is designed to be used with mountain peaks that are visible from where you're standing.
So how does the app PeakLens work on GMS as opposed to HMS? Let's take a quick look and find out.
PeakLens on GMS
On your first launch of PeakLens, you'll be taken through the quick setup process. The app requires several permissions from your GMS phone, including camera access, photo, and video recording access, and location permission. To begin using the app, you'll calibrate the compass by waving your phone in a "figure 8" motion.
Once the app is running, you'll be able to point your phone at visible mountain peaks and see their names and elevation. Your preferred unit of measurement can be changed in the settings section. The app works as it's supposed to, being a very simple way to gather quick information about your surrounding mountains.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
PeakLens on HMS
Getting this app for your HMS phone is simple, as it's hosted on the Huawei AppGallery. During the setup process, the HMS version of the app was able to calibrate much quicker than the GMS version, finishing about 15 seconds before the GMS version. This is significant since the app requires you to calibrate it every time you use it. Those additional 15 seconds save you a lot of time.
Since the HMS version of the app is made primarily for the Chinese market, you'll find that the names of targeted mountain peaks are shown in Chinese. Right now there isn't an option to change the language in the settings menu of this app.
With PeakLens running on HMS, you can expect it to function just as well as the GMS option. The app does not suffer from the lack of GMS, but rather it benefits from better performance on HMS.
Interesting. But it need an option to change the language.

Find Near & Around places based on your location: HMS Site, Location, Map Kit

r
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
​Hello, in this story I will give you an example of how to combine HMS Site, Location, and Map Kits. This application will allow you to display nearby restaurants, schools, shopping centers, etc. on the map based on your current location. First, will get the user’s location information with the Location kit. According to the location, we will search nearby places with one of the site kit’s features. Then we will display the received data on the map.
Get User's Location
First, you need to register as a Huawei Developer and complete the verification process. For detailed information please refer to the link below.
Register as a Developer
In AppGallery Connect console create a project and enable the Map, Site, and Location kits. You can follow the steps below:
AppGalleryConnect
To complete the implementation of kits we need to add dependencies on build.gradle file.
Last, add permissions on AndroidManifest.xml and we’re all set.
We need a permissionHandler class to manage location permissions.
In this app, I used the Android Navigation Component, that’s why all transactions will be in the MainFragment. To get user’s permission for location, call requestPermissions() method in onViewCreated(). We need 3 runtime permissions for location, so declare an array of permissions.
requestPermissions(PERMISSIONS, PERMISSION_ALL)
Create a FusedLocationProviderClient instance in onViewCreated() method :
Then call the getLastLocation() method right after instance. This method provides us user’s last known location. In most cases, the last known location is the current location of the device.
Now we have latitude and longitude information of the user’s device. Define two global double variables to hold lat and lng information. We will use these variables to get sites.
For nearby place parameters, set a string list in a spinner.
You can add more place options according to HMS Site kit HwLocationTypes below:
Location Kit
In onViewCreated method set an adapter for the spinner,
We will mark sites on the map according to the changed spinner item, first, we need to create a getSites() method to receive site information.
In this method, we request site data for the current location with the HwLocationType parameter that we received from the spinner onItemSelectedListener. And we marked each site location on the map with distance information. You can change NearbySearchRequest() parameters in your own way. For example, I set a radius of 5000 to get sites around 5K km from the user’s device location. But the only hwPoiType needs to be a dynamic value. Let’s set the dynamic value.
First, initialize map in onViewCreated method and extend OnMapReadyCallback.
Once you extend the map callback to the fragment, it asks you to add onMapReady method. In this method set the onItemSelected of the spinner.
Conclusion
So we get the user’s device's last known location, asked the user to choose a place to search for sites and we marked the received places on the map.
References
Demo Project
very detailed, thanks for sharing
i love it

How to use App Linking on non-Huawei phones?

Huawei’s App Linking allows for cross platform deep linking. How does this work on Non Huawei phones that don’t have HMS core installed? Lets take a look!
Lets start by testing App Linking on non-Huawei phones according to the information presented in the App Linking codelab.
I integrated App Linking into a demo app by following the instructions in the codelab, and set the link opening mode to AppGallery and the local app store respectively.
Setting the link opening mode to AppGallery:
Java:
AppLinking.Builder builder = new AppLinking.Builder()
.setUriPrefix(DOMAIN_URI_PREFIX)
.setDeepLink(Uri.parse(DEEP_LINK))
.setAndroidLinkInfo(new AppLinking.AndroidLinkInfo
.Builder()
.setOpenType(AppGallery)
.build())
Setting the link opening mode to the local app store:
Java:
AppLinking.Builder builder = new AppLinking.Builder()
.setUriPrefix(DOMAIN_URI_PREFIX)
.setDeepLink(Uri.parse(DEEP_LINK))
.setAndroidLinkInfo(new AppLinking.AndroidLinkInfo
.Builder()
.setOpenType(LocalMarket)
.build())
I then installed the demo app on two non-Huawei phones to test App Linking between Huawei phones and non-Huawei phones.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
As shown using the second code snippet we can see that App Linking is fully supported without the need of HMS Core. If the app has been installed on the non-Huawei phone, the in-app page can be directly opened without any problems.
If the app has not been installed on the non-Huawei phone and the link opening mode is AppGallery, the link will redirect the user to AppGallery. If AppGallery has not been installed, it will redirect the user to the AppGallery website.
If the app has not been installed on the non-Huawei phone and the link opening mode is set to local app store, the link will redirect the user to the local app store selected by the user. (Some mobile phone manufacturers will forcibly redirect the user to their own app store.)
Very useful sharing, thanks
Does it support a short link?

Huawei APM Network Analysis displaying the number of sessions as 0? Why?!

The APM service from AppGallery Connect can monitor and test the performance of apps running on devices and provide readable reports in real-time, which is a very practical feature.
Once integrated the analysis reports are very comprehensive, especially the ANR analysis and Network analysis reports.
However, there is one problem that many people find, which is that the number of sessions recorded in the network analysis appears as 0 even though the number of network requests, which appears as Samples in the following figure, was over one hundred.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
So why might this be the case? Is there something going wrong? A bug? What should we do about it?! Well, let’s start by understanding the sessions.
A session is an information interchange between the user and app. For example, when the user moves the app from the background to the foreground, a new session is generated.
To prevent frequently collected sessions from consuming too much traffic and CPU resources, APM performs sampling control on sessions.
Currently, the default session sampling rate is 1%.
The default session sampling rate is the preferred method when used online. But you can also increase it in the offline test by using the following code:
XML:
<application>
<!-- Set this value to '2.0', meaning only 2% of sessions can sample cpu and memory. -->
<meta-data
android:name="sessions_sampling_percentage"
android:value="2.0" />
</application>
Click here to view more details about how to set the session sampling rate.
So importantly not every session is sent back for reporting, and by default, it’s a very small number (1%). If you find that your app is getting a very low number of sessions, which is particularly the case during testing when it might just be running on one device increasing the sample percentage will help make sure you are getting sessions results in the reports.
If you want to learn more about APM, please refer to:
APM Development Guide
and
APM API Reference

FAQs Related to HMS Core Video Editor Kit

Question 1​
When my app accesses a material (such as a sticker) for a user, my app displays a message indicating that the access failed due to a network error and prompting the user to try again.
When my app uses an AI capability, the following information was displayed in my app's logs: errorCode:20124 errorMsg:Method not Allowed.
Solution
1. Check whether you have configured your app authentication information. If not, do so by following step 1 in the development guide.
2. Check whether you have enabled Video Editor Kit for your app. If not, enable the service either on HUAWEI Developers or in AppGallery Connect. After the service is enabled, due to factors such as network caches, it will take some time for the service to take effect for your app.
3. Check whether the signing certificate fingerprint in the Android Studio project code of your app is consistent with that configured in AppGallery Connect. If not, or you have not configured the fingerprint in the project code or AppGallery Connect, configure the fingerprint by following the instructions here. After you configure the fingerprint, due to factors such as network caches, it will take some time for the fingerprint to take effect for your app.
4. Check whether you have allocated the material in question.
5. Check whether you have applied for the AI capability you want.
If the problem persists, submit a ticket online (including your detailed logs and app ID) for troubleshooting.
Question 2​
After my app obtains a material column, the column name was either 101 or blank in my app.
Solution
1. Sign in to AppGallery Connect and select your desired project. In the navigation pane on the left, go to Grow > Video Editor Kit > App content operations > Column manager.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Click Delete columns.
3. Click Initialize columns.
4. Uninstall and then install the app.
Question 3​
When my app uses the AI filter of the fundamental capability SDK, my app receives no callback, and the Logcat window in Android Studio displays the following information: E/HVEExclusiveFilter: Failed resolution of: Lcom/huawei/hms/videoeditor/ai/imageedit/AIImageEditAnalyzerSetting$Factory;.
Cause
You did not add the dependencies necessary for the AI filter capability.
Solution
Add the following dependencies on the AI filter capability:
Code:
// Dependencies on the AI filter capability.
implementation 'com.huawei.hms:video-editor-ai-common:1.9.0.300'
implementation 'com.huawei.hms:video-editor-ai-imageedit:1.3.0.300'
implementation 'com.huawei.hms:video-editor-ai-imageedit-model:1.3.0.300'
Click here for more details.
Question 4​
My app is integrated with the fundamental capability SDK. After a video asset was added to the corresponding lane, my app called getSize or getPosition but obtained a null value.
Cause
When the getSize or getPosition method is called, the calculation of the video position in the preview area is not completed.
Solution
After adding a video asset to the lane, call seekTimeLine of HuaweiVideoEditor to begin calculation of the video position in the preview area. Calling seekTimeLine is an asynchronous operation. In its callback, you can obtain or set the size and position of an asset.
Below is an example:
Code:
// Specify the position of an asset on the preview area before adding the asset.
HuaweiVideoEditor.setDisplay(videoContentLayout);
Click here for more details.
Code:
// Add a video asset to the video lane.
HVEVideoAsset mHveVideoAsset= hveVideoLane.appendVideoAsset(sourceFile.getAbsolutePath());
mEditor.seekTimeLine(0, new HuaweiVideoEditor.SeekCallback() {
@Override
public void onSeekFinished() {
Log.d(TAG, "onSeekFinished: size:" + mHveVideoAsset.getSize() + ", position: " + mHveVideoAsset.getPosition()); }
});
References​
HMS Core Video Editor Kit home page
Development Guide of HMS Core Video Editor Kit

Categories

Resources