Following this thread, I can know how to detect if gms are installed.
In the same way, I want to know if hms (Huawei mobile services) are installed. According to this answer on stack overflow, both the methods are almost the same:
I tried to add this in B4A:
Also tried the inline Java code:
They do not work.
I've also added
in my project.
Any solution?
In the same way, I want to know if hms (Huawei mobile services) are installed. According to this answer on stack overflow, both the methods are almost the same:
Java:
public static boolean isHmsAvailable(Context context) {
boolean isAvailable = false;
if (null != context) {
int result = HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(context);
isAvailable = (com.huawei.hms.api.ConnectionResult.SUCCESS == result);
}
Log.i(TAG, "isHmsAvailable: " + isAvailable);
return isAvailable;
}
public static boolean isGmsAvailable(Context context) {
boolean isAvailable = false;
if (null != context) {
int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
isAvailable = (com.google.android.gms.common.ConnectionResult.SUCCESS == result);
}
Log.i(TAG, "isGmsAvailable: " + isAvailable);
return isAvailable;
}
I tried to add this in B4A:
B4X:
Sub CheckForHuaweiMobileServices As Boolean
Dim HuaweiApiAvailablity As JavaObject
HuaweiApiAvailablity = HuaweiApiAvailablity.InitializeStatic("HuaweiApiAvailability").RunMethod("getInstance", Null)
Dim context As JavaObject
context.InitializeContext
If HuaweiApiAvailablity.RunMethod("isHuaweiMobileServicesAvailable", Array(context)) <> 0 Then
Return False
End If
Return True
End Sub
Also tried the inline Java code:
B4X:
#If JAVA
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
import android.content.Context;
public BA ba;
Context context = ba.context;
public boolean isHmsAvailable() {
boolean isAvailable = false;
if (null != context) {
int result = HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(context);
isAvailable = (com.huawei.hms.api.ConnectionResult.SUCCESS == result);
}
Log.i(TAG, "isHmsAvailable: " + isAvailable);
return isAvailable;
}
#End If
They do not work.
I've also added
B4X:
#AdditionalJar: push-4.0.1.300.aar
Any solution?