use of com.google.android.gms.common.GooglePlayServicesRepairableException in project open-event-orga-app by fossasia.
the class CreateEventFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.event_create_layout, container, false);
validator = new Validator(binding.form);
AppCompatActivity activity = ((AppCompatActivity) getActivity());
activity.setSupportActionBar(binding.toolbar);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
setHasOptionsMenu(true);
binding.submit.setOnClickListener(view -> {
if (validator.validate())
getPresenter().createEvent();
});
// check if there's an google places API key
try {
ApplicationInfo ai = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String placesApiKey = bundle.getString("com.google.android.geo.API_KEY");
if ("YOUR_API_KEY".equals(placesApiKey)) {
Timber.d("Add Google Places API key in AndroidManifest.xml file to use Place Picker.");
binding.form.buttonPlacePicker.setVisibility(View.GONE);
binding.form.layoutLatitude.setVisibility(View.VISIBLE);
binding.form.layoutLongitude.setVisibility(View.VISIBLE);
showLocationLayouts();
}
} catch (PackageManager.NameNotFoundException e) {
Timber.e(e, "Package name not found");
}
binding.form.buttonPlacePicker.setOnClickListener(view -> {
int errorCode = googleApiAvailabilityInstance.isGooglePlayServicesAvailable(getContext());
if (errorCode == ConnectionResult.SUCCESS) {
// SUCCESS
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
try {
startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
Timber.d(e, "GooglePlayServicesRepairable");
} catch (GooglePlayServicesNotAvailableException e) {
Timber.d("GooglePlayServices NotAvailable => Updating or Unauthentic");
}
} else if (googleApiAvailabilityInstance.isUserResolvableError(errorCode)) {
// SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED
googleApiAvailabilityInstance.getErrorDialog(getActivity(), errorCode, PLACE_PICKER_REQUEST, (dialog) -> {
showLocationLayouts();
});
} else {
// SERVICE_UPDATING, SERVICE_INVALID - can't use place picker - must enter manually
showLocationLayouts();
}
});
adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
return binding.getRoot();
}
use of com.google.android.gms.common.GooglePlayServicesRepairableException in project react-native-google-places by tolu360.
the class RNGooglePlacesModule method openAutocompleteModal.
/**
* Exposed React's methods
*/
@ReactMethod
public void openAutocompleteModal(ReadableMap options, final Promise promise) {
this.pendingPromise = promise;
String type = options.getString("type");
String country = options.getString("country");
country = country.isEmpty() ? null : country;
boolean useOverlay = options.getBoolean("useOverlay");
double latitude = options.getDouble("latitude");
double longitude = options.getDouble("longitude");
double radius = options.getDouble("radius");
LatLng center = new LatLng(latitude, longitude);
Activity currentActivity = getCurrentActivity();
try {
// The autocomplete activity requires Google Play Services to be available. The intent
// builder checks this and throws an exception if it is not the case.
PlaceAutocomplete.IntentBuilder intentBuilder = new PlaceAutocomplete.IntentBuilder(useOverlay ? PlaceAutocomplete.MODE_OVERLAY : PlaceAutocomplete.MODE_FULLSCREEN);
if (latitude != 0 && longitude != 0 && radius != 0) {
intentBuilder.setBoundsBias(this.getLatLngBounds(center, radius));
}
Intent intent = intentBuilder.setFilter(getFilterType(type, country)).build(currentActivity);
currentActivity.startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);
} catch (GooglePlayServicesRepairableException e) {
// Indicates that Google Play Services is either not installed or not up to date. Prompt
// the user to correct the issue.
GoogleApiAvailability.getInstance().getErrorDialog(currentActivity, e.getConnectionStatusCode(), AUTOCOMPLETE_REQUEST_CODE).show();
} catch (GooglePlayServicesNotAvailableException e) {
// Indicates that Google Play Services is not available and the problem is not easily
// resolvable.
String message = "Google Play Services is not available: " + GoogleApiAvailability.getInstance().getErrorString(e.errorCode);
Log.e(TAG, message);
rejectPromise("E_INTENT_ERROR", new Error("Google Play Services is not available"));
}
}
use of com.google.android.gms.common.GooglePlayServicesRepairableException in project grpc-java by grpc.
the class TesterInstrumentation method onCreate.
@Override
public void onCreate(Bundle args) {
super.onCreate(args);
testCase = args.getString("test_case") != null ? args.getString("test_case") : "empty_unary";
host = args.getString("server_host");
port = Integer.parseInt(args.getString("server_port"));
serverHostOverride = args.getString("server_host_override");
useTls = args.getString("use_tls") != null ? Boolean.parseBoolean(args.getString("use_tls")) : true;
useTestCa = args.getString("use_test_ca") != null ? Boolean.parseBoolean(args.getString("use_test_ca")) : false;
androidSocketFactoryTls = args.getString("android_socket_factory_tls");
InputStream testCa = null;
if (useTestCa) {
testCa = getContext().getResources().openRawResource(R.raw.ca);
}
if (useTls) {
try {
ProviderInstaller.installIfNeeded(getContext());
} catch (GooglePlayServicesRepairableException e) {
// The provider is helpful, but it is possible to succeed without it.
// Hope that the system-provided libraries are new enough.
Log.w(InteropTester.LOG_TAG, "Failed installing security provider", e);
} catch (GooglePlayServicesNotAvailableException e) {
// The provider is helpful, but it is possible to succeed without it.
// Hope that the system-provided libraries are new enough.
Log.w(InteropTester.LOG_TAG, "Failed installing security provider", e);
}
}
try {
new InteropTester(testCase, TesterOkHttpChannelBuilder.build(host, port, serverHostOverride, useTls, testCa, androidSocketFactoryTls), new InteropTester.TestListener() {
@Override
public void onPreTest() {
}
@Override
public void onPostTest(String result) {
Bundle bundle = new Bundle();
bundle.putString("grpc test result", result);
if (InteropTester.SUCCESS_MESSAGE.equals(result)) {
finish(0, bundle);
} else {
finish(1, bundle);
}
}
}).execute();
} catch (Throwable t) {
Bundle bundle = new Bundle();
bundle.putString("Exception encountered", t.toString());
finish(1, bundle);
}
}
use of com.google.android.gms.common.GooglePlayServicesRepairableException in project UniPool by divya21raj.
the class NewEntryActivity method showPlaceAutocomplete.
private void showPlaceAutocomplete(int i) {
try {
AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder().setTypeFilter(Place.TYPE_COUNTRY).setCountry("IN").build();
Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).setFilter(autocompleteFilter).build(this);
startActivityForResult(intent, i);
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
Toast.makeText(this, "Google Play Service Error!", Toast.LENGTH_SHORT).show();
}
}
use of com.google.android.gms.common.GooglePlayServicesRepairableException in project react-native-google-places by tolu360.
the class RNGooglePlacesModule method openPlacePickerModal.
@ReactMethod
public void openPlacePickerModal(ReadableMap options, final Promise promise) {
this.pendingPromise = promise;
Activity currentActivity = getCurrentActivity();
double latitude = options.getDouble("latitude");
double longitude = options.getDouble("longitude");
double radius = options.getDouble("radius");
LatLng center = new LatLng(latitude, longitude);
try {
PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
if (latitude != 0 && longitude != 0 && radius != 0) {
intentBuilder.setLatLngBounds(this.getLatLngBounds(center, radius));
}
Intent intent = intentBuilder.build(currentActivity);
// Start the Intent by requesting a result, identified by a request code.
currentActivity.startActivityForResult(intent, PLACE_PICKER_REQUEST_CODE);
} catch (GooglePlayServicesRepairableException e) {
GoogleApiAvailability.getInstance().getErrorDialog(currentActivity, e.getConnectionStatusCode(), PLACE_PICKER_REQUEST_CODE).show();
} catch (GooglePlayServicesNotAvailableException e) {
rejectPromise("E_INTENT_ERROR", new Error("Google Play Services is not available"));
}
}
Aggregations