Android Question Playstore installed

Giusy

Active Member
Licensed User
Hi,
how to know if the user has playstore installed in his phone?
Thank you
 

Giusy

Active Member
Licensed User
Hi @Ohanian
In this code:
B4X:
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim jo As JavaObject
jo = jo.InitializeStatic("com.google.android.gms.common.GoogleApiAvailability").RunMethodJO("getInstance", Null)
Dim status As Int = jo.RunMethod("isGooglePlayServicesAvailable", Array (ctxt))
I have this error in the last row
 

Attachments

  • ERROR.JPG
    ERROR.JPG
    68.1 KB · Views: 135
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
Hi @Ohanian
In this code:
B4X:
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim jo As JavaObject
jo = jo.InitializeStatic("com.google.android.gms.common.GoogleApiAvailability").RunMethodJO("getInstance", Null)
Dim status As Int = jo.RunMethod("isGooglePlayServicesAvailable", Array (ctxt))
I have this error in the last row

Hi,

add this line to the main :
B4X:
#AdditionalJar: com.google.android.gms:play-services-base

and put these lines in the manifest :

B4X:
'************ Google Play Services Base ************
AddApplicationText(
   <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />
)
'************ Google Play Services Base (end) ************

and the status code is one these values :
B4X:
https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult
 
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
@Ohanian,
now it run correctly. thanks
I have on my device playstore installed and the status return 0
It's correct?

yes that's correct.

B4X:
public static final int SUCCESS
The connection was successful.

Constant Value: 0
 
Upvote 0
Top