Posts

Showing posts with the label Google Play Services

Android: Check If Location Services Enabled Using Fused Location Provider

Answer : This android developer training tutorial could help - here's the basics: Code to run in your Activity onCreate(): // Create an instance of GoogleAPIClient. if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } mGoogleApiClient.connect(); LocationRequest mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(10000); mLocationRequest.setFastestInterval(5000); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequest); PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build())...

Can I Edit The Text Of Sign In Button On Google?

Image
Answer : Here is the technique that I used: protected void setGooglePlusButtonText(SignInButton signInButton, String buttonText) { // Find the TextView that is inside of the SignInButton and set its text for (int i = 0; i < signInButton.getChildCount(); i++) { View v = signInButton.getChildAt(i); if (v instanceof TextView) { TextView tv = (TextView) v; tv.setText(buttonText); return; } } } Here is the easiest way that I used: TextView textView = (TextView) signInButton.getChildAt(0); textView.setText("your_text_xyz"); Problem: Other answers have mentioned a workaround. The underlying implementation of the button may change any time which would cause the code to break. I felt uncomfortable trying to use the hacks. For a clean solution, you would think that setting android:text on the com.google.android.gms.common.SignInButton in your layout file would do the trick. However it turns...

Android Studio ML Kit Cannot Load OCR Module

Answer : The solution was to update Google Play Services app. I did not consider this as an option at first as I would have expected an API 29 emulator to have an up-to-date Google Play Services installed. I signed into Google Play on the emulator, searched Google Play Services, uninstalled it (there was no "update" option), and installed it again. It still says that the installed version is 19.4.20 though the text recognition started working as expected. Here are some relevant logs: W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found. I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0 D/TextNativeHandle: Cannot load feature, fall back to load dynamite module. I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:1 I/DynamiteModule: Selected re...