Java 类com.google.android.gms.common.GooglePlayServicesNotAvailableException 实例源码

项目:cast-dashboard-android-app    文件:WeatherSettings.java   
@OnClick(R.id.weather_city)
public void selectCity() {

    //restrict to cities
    AutocompleteFilter cityFilter = new AutocompleteFilter.Builder()
            .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
            .build();
    try {
        Intent intent =
                new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
                        .setFilter(cityFilter)
                        .build(getActivity());
        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        // TODO: Handle the error.
    }
}
项目:aptoide-client    文件:AptoideUtils.java   
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;
        }
项目:travelers-diary    文件:ReminderItemFragment.java   
@OnClick(R.id.reminder_item_waypoint_title_text_view)
public void onWaypointTitleClick() {
    PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
    if (mRemindItem.getWaypoint() != null) {
        LocationPoint locationPoint = mRemindItem.getWaypoint().getLocation();
        LatLng latLng = new LatLng(locationPoint.getLatitude(), locationPoint.getLongitude());
        LatLngBounds latLngBounds = new LatLngBounds(latLng, latLng);
        builder.setLatLngBounds(latLngBounds);
    }

    Intent intent = null;
    try {
        intent = builder.build(getActivity());
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
    mProgressDialog = ProgressDialog.show(mContext,
            getString(R.string.reminder_place_picker_progress_dialog_title),
            getString(R.string.reminder_place_picker_progress_dialog_message), true, false);
    startActivityForResult(intent, PLACE_PICKER_REQUEST);
}
项目:PlacePicker    文件:PlacePickerActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_picker);
    mName = (TextView) findViewById(R.id.textView);
    mAddress = (TextView) findViewById(R.id.textView2);
    mAttributions = (TextView) findViewById(R.id.textView3);
    Button pickerButton = (Button) findViewById(R.id.pickerButton);
    pickerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                PlacePicker.IntentBuilder intentBuilder =
                        new PlacePicker.IntentBuilder();
                intentBuilder.setLatLngBounds(BOUNDS_MOUNTAIN_VIEW);
                Intent intent = intentBuilder.build(PlacePickerActivity.this);
                startActivityForResult(intent, PLACE_PICKER_REQUEST);

            } catch (GooglePlayServicesRepairableException
                    | GooglePlayServicesNotAvailableException e) {
                e.printStackTrace();
            }
        }
    });
}
项目:flavordex    文件:Endpoint.java   
/**
 * Constructor.
 *
 * @param context The Context to use
 */
Endpoint(@NonNull Context context) {
    try {
        ProviderInstaller.installIfNeeded(context);
    } catch(GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        Log.e(TAG, e.getMessage(), e);
    }

    mContext = context;

    final OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .connectTimeout(30, TimeUnit.SECONDS);
    configureSSL(builder);
    mClient = builder.build();

    final String apiUri =
            context.getString(BuildConfig.DEBUG ? R.string.api_url_debug : R.string.api_url);
    mBaseUrl = HttpUrl.parse(apiUri).newBuilder()
            .addEncodedPathSegment(getName())
            .build();
    mUserAgent = context.getString(R.string.user_agent, BuildConfig.VERSION_NAME);

    loadAuthToken();
}
项目:PlaceApiAutocompleteWidget    文件:MainActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_search) {
        // Method #3
        try {
            Intent intent = new PlaceAutocomplete.IntentBuilder
                    (PlaceAutocomplete.MODE_OVERLAY)
                    .setBoundsBias(BOUNDS_MOUNTAIN_VIEW)
                    .build(MainActivity.this);
            startActivityForResult(intent, REQUEST_SELECT_PLACE);
        } catch (GooglePlayServicesRepairableException |
                GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}
项目:FMTech    文件:ProviderInstaller.java   
public static void installIfNeededAsync(Context paramContext, final ProviderInstallListener paramProviderInstallListener)
{
  zzx.zzb(paramContext, "Context must not be null");
  zzx.zzb(paramProviderInstallListener, "Listener must not be null");
  zzx.zzcx("Must be called on the UI thread");
  new AsyncTask()
  {
    private Integer zzc$9ecd34e()
    {
      try
      {
        ProviderInstaller.installIfNeeded(this.zzsR);
        return Integer.valueOf(0);
      }
      catch (GooglePlayServicesRepairableException localGooglePlayServicesRepairableException)
      {
        return Integer.valueOf(localGooglePlayServicesRepairableException.zzVA);
      }
      catch (GooglePlayServicesNotAvailableException localGooglePlayServicesNotAvailableException)
      {
        return Integer.valueOf(localGooglePlayServicesNotAvailableException.errorCode);
      }
    }
  }.execute(new Void[0]);
}
项目:FMTech    文件:GoogleAuthUtil.java   
public static PendingIntent getRecoveryIfSuggested$12f08959(Context paramContext, String paramString)
  throws IOException, UserRecoverableAuthException, GoogleAuthException
{
  zzx.zzcy("Calling this from your main thread can lead to deadlock");
  try
  {
    GooglePlayServicesUtil.zzae(paramContext.getApplicationContext());
    final Bundle localBundle = new Bundle();
    localBundle.putString(KEY_ANDROID_PACKAGE_NAME, paramContext.getPackageName());
    zza local3 = new zza() {};
    RecoveryDecision localRecoveryDecision = (RecoveryDecision)zza(paramContext, zzVm, local3);
    if ((localRecoveryDecision.showRecoveryInterstitial) && (localRecoveryDecision.isRecoveryInterstitialAllowed)) {
      return localRecoveryDecision.recoveryIntent;
    }
  }
  catch (GooglePlayServicesRepairableException localGooglePlayServicesRepairableException)
  {
    throw new GooglePlayServicesAvailabilityException(localGooglePlayServicesRepairableException.zzVA, localGooglePlayServicesRepairableException.getMessage(), new Intent(localGooglePlayServicesRepairableException.mIntent));
  }
  catch (GooglePlayServicesNotAvailableException localGooglePlayServicesNotAvailableException)
  {
    throw new GoogleAuthException(localGooglePlayServicesNotAvailableException.getMessage());
  }
  return null;
}
项目:FMTech    文件:AdvertisingIdClient.java   
public void zzb(boolean paramBoolean)
  throws IOException, IllegalStateException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException
{
  zzx.zzcy("Calling this from your main thread can lead to deadlock");
  try
  {
    if (this.zzpg) {
      finish();
    }
    this.zzpe = zzq(this.mContext);
    this.zzpf = zza$4541938d(this.zzpe);
    this.zzpg = true;
    if (paramBoolean) {
      zzaW();
    }
    return;
  }
  finally {}
}
项目:FMTech    文件:GmpMeasurement.java   
private static zzjz zzY(Context paramContext)
  throws GooglePlayServicesNotAvailableException
{
  synchronized (zzqK)
  {
    if (zzNn == null)
    {
      if (paramContext.getApplicationContext() != null) {
        paramContext = paramContext.getApplicationContext();
      }
      zzNn = zzjy.zzaa(paramContext);
    }
    zzjz localzzjz = zzNn;
    return localzzjz;
  }
}
项目:BookMySkills    文件:MyHomeFragment.java   
private void initializeMap() throws GooglePlayServicesNotAvailableException {
    try {
        MapsInitializer.initialize(getActivity());
        if (getActivity().getSupportFragmentManager().findFragmentById(
                R.id.mapContainer) == null) {
            mapSupportFragment = MySupportMapFragment
                    .newInstatnce(new Bundle());
            mapSupportFragment.setTargetFragment(this, 100);
            if (getArguments() != null)
                mapSupportFragment.setArguments(getArguments());

            getActivity().getSupportFragmentManager().beginTransaction()
                    .add(R.id.mapContainer, mapSupportFragment).commit();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:libertacao-android    文件:EditEventActivity.java   
/**
 * Pick place
 * https://medium.com/@hitherejoe/exploring-play-services-place-picker-autocomplete-150809f739fe
 */
@Override
public void onPickEventPlaceClick() {
    PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
    if(editEventDataModel.getEvent().hasLocation()) {
        double longitude = editEventDataModel.getEvent().getLongitude();
        double latitude = editEventDataModel.getEvent().getLatitude();
        double offset = 0.01;
        LatLng southwest = new LatLng(latitude - offset, longitude - offset);
        LatLng northeast = new LatLng(latitude + offset, longitude + offset);
        intentBuilder.setLatLngBounds(new LatLngBounds(southwest, northeast));
    }
    try {
        startActivityForResult(intentBuilder.build(this), PLACE_PICKER_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
        Toast.makeText(this, getString(R.string.unknown_error), Toast.LENGTH_LONG).show();
    }
}
项目:travelers-diary    文件:ReminderItemFragment.java   
@OnClick(R.id.reminder_item_waypoint_title_text_view)
public void onWaypointTitleClick() {
    PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
    if (mRemindItem.getWaypoint() != null) {
        LocationPoint locationPoint = mRemindItem.getWaypoint().getLocation();
        LatLng latLng = new LatLng(locationPoint.getLatitude(), locationPoint.getLongitude());
        LatLngBounds latLngBounds = new LatLngBounds(latLng, latLng);
        builder.setLatLngBounds(latLngBounds);
    }

    Intent intent = null;
    try {
        intent = builder.build(getActivity());
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
    mProgressDialog = ProgressDialog.show(mContext,
            getString(R.string.reminder_place_picker_progress_dialog_title),
            getString(R.string.reminder_place_picker_progress_dialog_message), true, false);
    startActivityForResult(intent, PLACE_PICKER_REQUEST);
}
项目:QuizUpWinner    文件:GoogleAuthUtil.java   
private static void m(Context paramContext)
{
  try
  {
    GooglePlayServicesUtil.m(paramContext);
    return;
  }
  catch (GooglePlayServicesRepairableException localGooglePlayServicesRepairableException)
  {
    throw new GooglePlayServicesAvailabilityException(localGooglePlayServicesRepairableException.getConnectionStatusCode(), localGooglePlayServicesRepairableException.getMessage(), localGooglePlayServicesRepairableException.getIntent());
  }
  catch (GooglePlayServicesNotAvailableException localGooglePlayServicesNotAvailableException)
  {
    throw new GoogleAuthException(localGooglePlayServicesNotAvailableException.getMessage());
  }
}
项目:QuizUpWinner    文件:MapsInitializer.java   
public static int initialize(Context paramContext)
{
  eg.f(paramContext);
  c localc;
  try
  {
    localc = q.u(paramContext);
  }
  catch (GooglePlayServicesNotAvailableException localGooglePlayServicesNotAvailableException)
  {
    return localGooglePlayServicesNotAvailableException.errorCode;
  }
  try
  {
    CameraUpdateFactory.a(localc.ez());
    BitmapDescriptorFactory.a(localc.eA());
  }
  catch (RemoteException localRemoteException)
  {
    throw new RuntimeRemoteException(localRemoteException);
  }
  return 0;
}
项目:TweetyHunting    文件:TweetingActivity.java   
public void updateAdvertisingId() {

        new Thread(new Runnable() {
            @Override
            public void run() {
                AdvertisingIdClient.Info adInfo = null;
                try {
                    adInfo = AdvertisingIdClient.getAdvertisingIdInfo(TweetingActivity.this);

                } catch (IOException | GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException exception) {
                    // Unrecoverable error connecting to Google Play services (e.g.,
                    // the old version of the service doesn't support getting AdvertisingId).

                }
                if (adInfo != null) {
                    mAdversitingId = adInfo.getId();
                }
            }
        });
    }
项目:Purdue-App-Old    文件:MapActivity.java   
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Log event
    Log.d(LOG_MAP_TAG, "MapActivity : onCreate() called.");

    // Set the content view with a google map fragment
    setContentView(R.layout.map_activity_main);

    // Create the fragments for the UI
    MapActivityEventListener eventListener = new MapActivityEventListener(this);
    gmapFragment = ((GoogleMapFragment) getFragmentManager().findFragmentById(R.id.map_fragment_googlemapfragment));
    gmapFragment.setGMapFragmentLoadedListener(eventListener);
    buildingFragment = new BuildingListDialog();
    buildingFragment.setOnBuildingSelectedListener(eventListener);

    // Prepare MapData
    mpd = new MapData(this);

    // Initialize the gms maps services
    try {
        MapsInitializer.initialize(this);
    } catch (GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
}
项目:GeoFencingDemo    文件:LocationActivity.java   
private void showMap(Bundle savedInstanceState) {
  try {
    MapsInitializer.initialize(getBaseContext());
  } catch (GooglePlayServicesNotAvailableException e) {
    e.printStackTrace();
  }
  GoogleMapOptions options = new GoogleMapOptions();
  options.mapType(GoogleMap.MAP_TYPE_NORMAL);
  options.zoomControlsEnabled(true);
  mapView = new MapView(this, options);
  mapView.onCreate(savedInstanceState);
  mapView.onResume();
  mapView.setEnabled(true);
  googleMap = mapView.getMap();
  if (googleMap != null) {
    googleMap.setMyLocationEnabled(true);
  }
  mapLayout.addView(mapView);
}
项目:PeSanKita-android    文件:AttachmentManager.java   
public static void selectLocation(Activity activity, int requestCode) {
  try {
    activity.startActivityForResult(new PlacePicker.IntentBuilder().build(activity), requestCode);
  } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
    Log.w(TAG, e);
  }
}
项目:openlocate-android    文件:FetchAdvertisingInfoTask.java   
@Override
protected Void doInBackground(Void... params) {
    try {
        info = AdvertisingIdClient.getAdvertisingIdInfo(context);
    } catch (IOException
            | GooglePlayServicesNotAvailableException
            | GooglePlayServicesRepairableException e) {
        Log.e(TAG, e.getMessage());
    }

    return null;
}
项目:mapbox-navigation-hud-demo    文件:GeocodeActivity.java   
private void launchSearchAutocomplete() {
  try {
    Intent intent =
      new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
        .build(this);
    startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
  } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
    Log.e(TAG, e.getMessage());
  }
}
项目:Udacity_Sunshine    文件:LocationEditTextPreference.java   
@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;
}
项目:Sega    文件:ProfileDetailFragment.java   
private void locationPlacesIntent() {

        try {
            PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
            startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST);
        } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
    }
项目:Sega    文件:AddProductActivity.java   
private void locationPlacesIntent() {

        try {
            PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
            startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
        } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
    }
项目:Sega    文件:ChatActivity.java   
/**
 * Obter local do usuario
 */
private void locationPlacesIntent() {

    try {
        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
}
项目:bikedeboa-android    文件:MapActivity.java   
@Override
public void onClick(View v) {
    try {
        // Launch autocomplete activity
        Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
                .setFilter(new AutocompleteFilter.Builder()
                        .setCountry("BR")
                        .build())
                .build(MapActivity.this);
        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        // TODO: Handle the error.
    }
}
项目:Advanced_Android_Development_Wear    文件:LocationEditTextPreference.java   
@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(settingsActivity), 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;
}
项目:directly    文件:NewToiletFragment.java   
public void showLocationChooser() {
    try {
        Intent intent =
                new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
                        .build(getActivity());
        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        Timber.e(e, "", "");
    }
}
项目:directly    文件:ToiletListFragment.java   
public void showLocationChooser() {
    try {
        Intent intent =
                new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
                        .build(getActivity());
        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        Timber.e(e, "", "");
    }
}
项目:cast-dashboard-android-app    文件:MapSettings.java   
@OnClick(R.id.map_location)
public void getLocation() {
    try {
        Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).build(getActivity());
        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        Log.e(MainActivity.TAG, e.toString());
    }
}
项目:cast-dashboard-android-app    文件:MapSettings.java   
@OnClick(R.id.map_destination)
public void getDestination() {
    try {
        Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).build(getActivity());
        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE_DESTINATION);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        Log.e(MainActivity.TAG, e.toString());
    }
}
项目:aptoide-client    文件:AptoideUtils.java   
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;
        }
项目:aptoide-client    文件:UpdatesService.java   
private String getAdvertisementId() {
    try {
        return AdvertisingIdClient.getAdvertisingIdInfo(Aptoide.getContext()).getId();
    } catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {
        Logger.printException(e);
    }
    return null;
}
项目:Popdeem-SDK-Android    文件:PDUniqueIdentifierUtils.java   
@Override
protected String doInBackground(Void... params) {
    try {
        AdvertisingIdClient.Info info = AdvertisingIdClient.getAdvertisingIdInfo(mContext);
        success = true;
        return info.getId();
    } catch (IOException | GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {
        e.printStackTrace();
        success = false;
        return e.getMessage();
    }
}
项目:qiscus-sdk-android    文件:QiscusBaseChatFragment.java   
protected void addLocation() {
    if (QiscusPermissionsUtil.hasPermissions(getActivity(), LOCATION_PERMISSION)) {
        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        try {
            startActivityForResult(builder.build(getActivity()), PICK_LOCATION_REQUEST);
        } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
        hideAttachmentPanel();
    } else {
        requestAddLocationPermission();
    }
}
项目:androidprojectbase    文件:PlacesAutoCompleteSample.java   
private void callPlaceAutocompleteActivityIntent() {
    try {
        // Change MODE for dialog PlaceAutocomplete.MODE_OVERLAY
        // Usage limits do not apply to the autocomplete widget.
        Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
                        .build(this);
        startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        // TODO: Handle the error.
    }

}
项目:RoboCat    文件:RoutePlanFragment.java   
@OnClick(R.id.et_start_location)
void onFromClick() {
    // Starts Google Place Picker UI control
    try {
        if (!isGooglePlacePickerAlreadyOpen) {
            isGooglePlacePickerAlreadyOpen = true;
            startActivityForResult(builder.build(getActivity()),
                    REQUEST_CODE_STARTING_POINT);
        }
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
}
项目:RoboCat    文件:RoutePlanFragment.java   
@OnClick(R.id.et_destination_location)
void onToClick() {
    // Starts Google Place Picker UI control
    try {
        if (!isGooglePlacePickerAlreadyOpen) {
            isGooglePlacePickerAlreadyOpen = true;
            startActivityForResult(builder.build(getActivity()),
                    REQUEST_CODE_DESTINATION_POINT);
        }
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
}
项目:SplitApp    文件:NewEventDetailsActivity.java   
private void setLocationPicker() {
    mLocationLabel = (TextView) findViewById(R.id.location_label);
    RelativeLayout location = (RelativeLayout) findViewById(R.id.location_lay);
    location.setOnClickListener(v -> {
        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        try {
            startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
        } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
    });
}
项目:Sunshine_WeatherApp    文件:LocationEditTextPreference.java   
@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((Activity)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.
                Log.d( "LocationEditTextPref", e + " thrown" );
            }
        }
    });

    return view;
}