Why is LocationSettingsResult startResolutionForResult not calling onActivityResult?

后端 未结 5 1215
悲&欢浪女
悲&欢浪女 2021-02-15 04:33

I\'ve seen this Q&A LocationSettingsRequest dialog - onActivityResult() skipped. It isn\'t the same issue because everything is being done in an Activity already.

Th

相关标签:
5条回答
  • 2021-02-15 04:52

    If anyone has stumbled on to this problem, gianlucaparadise's answer is one of the better way's of solving this problem. Although the answer is deleted, it adds a lot of value.

    0 讨论(0)
  • 2021-02-15 05:01

    In my case there was this error: I've used

    public abstract class AGoogleDriveBase extends ABase implements
            GoogleApiClient.ConnectionCallbacks,
            GoogleApiClient.OnConnectionFailedListener {
    //...
    @Override
        protected void onActivityResult(int requestCode, int resultCode,  Intent data) {
    //...
    

    and this function not called using

    try {
                result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
            } catch (SendIntentException e) {
                Log.e(TAG, "Exception while starting resolution activity", e);
            }
    

    because when I used a main activity

    public class myAct extends AGoogleDriveBase implements ... {
    //...
    @Override
          protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    

    the super method not called (not existed this string):

     super.onActivityResult(requestCode, resultCode, data);
    
    0 讨论(0)
  • 2021-02-15 05:11

    You can check out the Google Play Location Sample since your code is quite similar it.

    From what I can tell on your samples, onResult() may not be called because the case is not LocationSettingsStatusCodes.RESOLUTION_REQUIRED. Its not calling the startResolutionForResult or an underlying setActivityForResult inside it.

    0 讨论(0)
  • 2021-02-15 05:12

    If you are running this code in Fragment than don't use startResolutionForResult(). Instead use startIntentSenderForResult(status.getResolution().getIntentSender(), REQUEST_CODE_LOCATION_SETTING, null, 0, 0, 0, null);

    and overrider onaActivityResult() in your fragment. Result will be delivered to this method only.

    0 讨论(0)
  • 2021-02-15 05:12

    Well I feel silly. My Activity had noHistory="true" in the Manifest so when the other Activity was started there was nothing to come back to.

    0 讨论(0)
提交回复
热议问题