com.google.android.gms.common.GooglePlayServicesRepairableException Java Examples
The following examples show how to use
com.google.android.gms.common.GooglePlayServicesRepairableException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AptoideUtils.java From aptoide-client with GNU General Public License v2.0 | 6 votes |
public static String parseString(Context context, String clickUrl) throws IOException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException { String deviceId = android.provider.Settings.Secure.getString(Aptoide.getContext().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); String myid = PreferenceManager.getDefaultSharedPreferences(context).getString(EnumPreferences.APTOIDE_CLIENT_UUID.name(), "NoInfo"); if (deviceId != null) { clickUrl = clickUrl.replace("[USER_ANDROID_ID]", deviceId); } if (myid != null) { clickUrl = clickUrl.replace("[USER_UDID]", myid); } clickUrl = replaceAdvertisementId(clickUrl, context); clickUrl = clickUrl.replace("[TIME_STAMP]", String.valueOf(new Date().getTime())); return clickUrl; }
Example #2
Source File: WelcomeActivity.java From cronet-sample with Apache License 2.0 | 6 votes |
public void openImages(View view) { Task<Void> installTask = CronetProviderInstaller.installProvider(this); installTask.addOnCompleteListener( task -> { if (task.isSuccessful()) { Intent mpdIntent = new Intent(this, MainActivity.class); startActivity(mpdIntent); } else if (task.getException() != null) { Exception cause = task.getException(); if (cause instanceof GooglePlayServicesNotAvailableException) { Toast.makeText(this, "Google Play services not available.", Toast.LENGTH_SHORT).show(); } else if (cause instanceof GooglePlayServicesRepairableException) { Toast.makeText(this, "Google Play services update is required.", Toast.LENGTH_SHORT).show(); startActivity(((GooglePlayServicesRepairableException) cause).getIntent()); } else { Toast.makeText(this, "Unexpected error: " + cause, Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(this, "Unable to load Google Play services.", Toast.LENGTH_SHORT).show(); } }); }
Example #3
Source File: GrpcCallProvider.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
/** Sets up the SSL provider and configures the gRPC channel. */ private ManagedChannel initChannel(Context context, DatabaseInfo databaseInfo) { try { // We need to upgrade the Security Provider before any network channels are initialized. // `OkHttp` maintains a list of supported providers that is initialized when the JVM first // resolves the static dependencies of ManagedChannel. ProviderInstaller.installIfNeeded(context); } catch (GooglePlayServicesNotAvailableException /* Thrown by ProviderInstaller */ | GooglePlayServicesRepairableException /* Thrown by ProviderInstaller */ | IllegalStateException e /* Thrown by Robolectric */) { // Mark the SSL initialization as done, even though we may be using outdated SSL // ciphers. gRPC-Java recommends obtaining updated ciphers from GMSCore, but we allow // the device to fall back to other SSL ciphers if GMSCore is not available. Logger.warn(LOG_TAG, "Failed to update ssl context: %s", e); } ManagedChannelBuilder<?> channelBuilder; if (overrideChannelBuilderSupplier != null) { channelBuilder = overrideChannelBuilderSupplier.get(); } else { channelBuilder = ManagedChannelBuilder.forTarget(databaseInfo.getHost()); if (!databaseInfo.isSslEnabled()) { // Note that the boolean flag does *NOT* switch the wire format from Protobuf to Plaintext. // It merely turns off SSL encryption. channelBuilder.usePlaintext(); } } // Ensure gRPC recovers from a dead connection. (Not typically necessary, as the OS will // usually notify gRPC when a connection dies. But not always. This acts as a failsafe.) channelBuilder.keepAliveTime(30, TimeUnit.SECONDS); // Wrap the ManagedChannelBuilder in an AndroidChannelBuilder. This allows the channel to // respond more gracefully to network change events (such as switching from cell to wifi). AndroidChannelBuilder androidChannelBuilder = AndroidChannelBuilder.usingBuilder(channelBuilder).context(context); return androidChannelBuilder.build(); }
Example #4
Source File: ProviderInstaller.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
public void install() { try { com.google.android.gms.security.ProviderInstaller.installIfNeeded(application); } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { e.printStackTrace(); } }
Example #5
Source File: EventEditActivity.java From NaviBee with GNU General Public License v3.0 | 5 votes |
public void showPlacePicker(View view) { locationLayout.setError(null); try { PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST); } catch ( GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException ignored) { } }
Example #6
Source File: FetchAdvertisingInfoTask.java From openlocate-android with MIT License | 5 votes |
@Override protected Void doInBackground(Void... params) { try { info = AdvertisingIdClient.getAdvertisingIdInfo(context); } catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { Log.e(TAG, e.getMessage() != null ? e.getMessage() : "Failed to get ad id."); } return null; }
Example #7
Source File: AptoideUtils.java From aptoide-client with GNU General Public License v2.0 | 5 votes |
private static String replaceAdvertisementId(String clickUrl, Context context) throws IOException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException { String aaId = ""; if (GoogleServices.checkGooglePlayServices(context)) { if (AptoideUtils.getSharedPreferences().contains("advertisingIdClient")) { aaId = AptoideUtils.getSharedPreferences().getString("advertisingIdClient", ""); } else { try { aaId = AdvertisingIdClient.getAdvertisingIdInfo(context).getId(); } catch (Exception e) { // In case we try to do this from a Broadcast Receiver, exception will be thrown. Logger.w("AptoideUtils", e.getMessage()); } } } else { byte[] data = new byte[16]; String deviceId = android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); SecureRandom secureRandom = new SecureRandom(); secureRandom.setSeed(deviceId.hashCode()); secureRandom.nextBytes(data); aaId = UUID.nameUUIDFromBytes(data).toString(); } clickUrl = clickUrl.replace("[USER_AAID]", aaId); return clickUrl; }
Example #8
Source File: UpdatesService.java From aptoide-client with GNU General Public License v2.0 | 5 votes |
private String getAdvertisementId() { try { return AdvertisingIdClient.getAdvertisingIdInfo(Aptoide.getContext()).getId(); } catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { Logger.printException(e); } return null; }
Example #9
Source File: LocationEditTextPreference.java From Advanced_Android_Development with Apache License 2.0 | 5 votes |
@Override protected View onCreateView(ViewGroup parent) { View view = super.onCreateView(parent); View currentLocation = view.findViewById(R.id.current_location); currentLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context context = getContext(); // Launch the Place Picker so that the user can specify their location, and then // return the result to SettingsActivity. PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); // We are in a view right now, not an activity. So we need to get ourselves // an activity that we can use to start our Place Picker intent. By using // SettingsActivity in this way, we can ensure the result of the Place Picker // intent comes to the right place for us to process it. Activity settingsActivity = (SettingsActivity) context; try { settingsActivity.startActivityForResult( builder.build(context), SettingsActivity.PLACE_PICKER_REQUEST); } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { // What did you do?? This is why we check Google Play services in onResume!!! // The difference in these exception types is the difference between pausing // for a moment to prompt the user to update/install/enable Play services vs // complete and utter failure. // If you prefer to manage Google Play services dynamically, then you can do so // by responding to these exceptions in the right moment. But I prefer a cleaner // user experience, which is why you check all of this when the app resumes, // and then disable/enable features based on that availability. } } }); return view; }
Example #10
Source File: APDE.java From APDE with GNU General Public License v2.0 | 5 votes |
/** * Disable SSL3 to force TLS. Fix for Android 4.4 and below. * * https://stackoverflow.com/questions/29916962/javax-net-ssl-sslhandshakeexception-javax-net-ssl-sslprotocolexception-ssl-han */ public void disableSsl3() { try { ProviderInstaller.installIfNeeded(this); } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { // Too bad System.err.println("Failed to disable SSL3"); } }
Example #11
Source File: MainActivity.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
/** * Determinate what sections are supported */ private void collectData() { MainActivity activity = mRefActivity.get(); if (activity == null) return; Battery.getInstance(activity); CPUBoost.getInstance(); // Assign core ctl min cpu CPUFreq.getInstance(activity); Device.CPUInfo.getInstance(); Device.Input.getInstance(); Device.MemInfo.getInstance(); Device.ROMInfo.getInstance(); Device.TrustZone.getInstance(); GPU.supported(); Hotplug.supported(); IO.getInstance(); KSM.getInstance(); MSMPerformance.getInstance(); QcomBcl.supported(); Screen.supported(); Sound.getInstance(); Temperature.getInstance(activity); Thermal.supported(); Tile.publishProfileTile(new Profiles(activity).getAllProfiles(), activity); Vibration.getInstance(); Voltage.getInstance(); Wake.supported(); try { ProviderInstaller.installIfNeeded(activity); } catch (GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) { e.printStackTrace(); } if (!BuildConfig.DEBUG) { // Send SoC type to analytics to collect stats Answers.getInstance().logCustom(new CustomEvent("SoC") .putCustomAttribute("type", Device.getBoard())); } Log.crashlyticsI(TAG, "Build Display ID: " + Device.getBuildDisplayId()); Log.crashlyticsI(TAG, "ROM: " + Device.ROMInfo.getInstance().getVersion()); Log.crashlyticsI(TAG, "Kernel version: " + Device.getKernelVersion(true)); Log.crashlyticsI(TAG, "Board: " + Device.getBoard()); }