当前位置: 首页>>代码示例>>Java>>正文


Java Task.addOnSuccessListener方法代码示例

本文整理汇总了Java中com.google.android.gms.tasks.Task.addOnSuccessListener方法的典型用法代码示例。如果您正苦于以下问题:Java Task.addOnSuccessListener方法的具体用法?Java Task.addOnSuccessListener怎么用?Java Task.addOnSuccessListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.tasks.Task的用法示例。


在下文中一共展示了Task.addOnSuccessListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendRegisterRequestToClient

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
private void sendRegisterRequestToClient(RegisterRequestParams registerRequestParams) {
    U2fApiClient u2fApiClient = Fido.getU2fApiClient(this.getApplicationContext());

    Task<U2fPendingIntent> result = u2fApiClient.getRegisterIntent(registerRequestParams);

    result.addOnSuccessListener(new OnSuccessListener<U2fPendingIntent>() {
        @Override
        public void onSuccess(U2fPendingIntent u2fPendingIntent) {
            if (u2fPendingIntent.hasPendingIntent()) {
                try {
                    u2fPendingIntent
                            .launchPendingIntent(U2FDemoActivity.this, REQUEST_CODE_REGISTER);
                    Log.i(TAG, "register_request is sent out");
                } catch (IntentSender.SendIntentException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:21,代码来源:U2FDemoActivity.java

示例2: sendSignRequestToClient

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
private void sendSignRequestToClient(SignRequestParams signRequestParams) {
    U2fApiClient u2fApiClient = Fido.getU2fApiClient(this.getApplicationContext());

    Task<U2fPendingIntent> result = u2fApiClient.getSignIntent(signRequestParams);

    result.addOnSuccessListener(new OnSuccessListener<U2fPendingIntent>() {
        @Override
        public void onSuccess(U2fPendingIntent u2fPendingIntent) {
            if (u2fPendingIntent.hasPendingIntent()) {
                try {
                    u2fPendingIntent
                            .launchPendingIntent(U2FDemoActivity.this, REQUEST_CODE_SIGN);
                } catch (IntentSender.SendIntentException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
 
开发者ID:googlesamples,项目名称:android-fido,代码行数:20,代码来源:U2FDemoActivity.java

示例3: assignOnTask

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
public static <T> void assignOnTask(MaybeEmitter<? super T> emitter, Task<T> task) {
    RxHandler handler = new RxHandler(emitter);
    task.addOnSuccessListener(handler);
    task.addOnFailureListener(handler);
    try {
        task.addOnCompleteListener(handler);
    } catch (Throwable t) {
        // ignore
    }
}
 
开发者ID:DVT,项目名称:showcase-android,代码行数:11,代码来源:RxHandler.java

示例4: assignOnTask

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
public static <T> void assignOnTask(CompletableEmitter completableEmitter, Task<T> task) {
   RxCompletableHandler handler = new RxCompletableHandler(completableEmitter);
   task.addOnFailureListener(handler);
   task.addOnSuccessListener(handler);
   try {
      task.addOnCompleteListener(handler);
   } catch (Throwable t) {
      // ignore
   }
}
 
开发者ID:DVT,项目名称:showcase-android,代码行数:11,代码来源:RxCompletableHandler.java

示例5: setUpLocationRequest

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
public void setUpLocationRequest(OnSuccessListener<LocationSettingsResponse> successListener,
    OnFailureListener onFailureListener) {
  LocationRequest locationRequest = getLocationRequest();
  LocationSettingsRequest.Builder builder =
      new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
  SettingsClient settingsClient = LocationServices.getSettingsClient(context);
  Task<LocationSettingsResponse> locationSettingsResponseTask =
      settingsClient.checkLocationSettings(builder.build());

  locationSettingsResponseTask.addOnSuccessListener(successListener);

  locationSettingsResponseTask.addOnFailureListener(onFailureListener);
}
 
开发者ID:Arjun-sna,项目名称:LocationAware,代码行数:14,代码来源:LocationProvider.java

示例6: setupLocationService

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
private void setupLocationService() {
    Log.v(TAG, "Setting up location service");
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
            .addLocationRequest(getLocationRequest());
    SettingsClient client = LocationServices.getSettingsClient(activity);
    Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build());

    task.addOnSuccessListener(activity, new OnSuccessListener<LocationSettingsResponse>() {
        @Override
        public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
            Log.v(TAG, "Location settings satisfied");
        }
    });

    task.addOnFailureListener(activity, new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            int statusCode = ((ApiException) e).getStatusCode();
            switch (statusCode) {
                case CommonStatusCodes.RESOLUTION_REQUIRED:
                    Log.w(TAG, "Location settings not satisfied, attempting resolution intent");
                    try {
                        ResolvableApiException resolvable = (ResolvableApiException) e;
                        resolvable.startResolutionForResult(activity, REQUEST_CODE_LOCATION_SETTINGS);
                    } catch (IntentSender.SendIntentException sendIntentException) {
                        Log.e(TAG, "Unable to start resolution intent");
                    }
                    break;
                case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                    Log.w(TAG, "Location settings not satisfied and can't be changed");
                    break;
            }
        }
    });
}
 
开发者ID:neXenio,项目名称:BLE-Indoor-Positioning,代码行数:36,代码来源:AndroidLocationProvider.java

示例7: startLocationService

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
/**
 * Method to check for the location settings of the device,
 * if it doesn't fit the current requirement of the app
 * open the settings for user to change them, if the settings are OK, starts the TimeService.
 */

@Override
public void startLocationService() {
    LocationRequest request = new LocationRequest()
            .setFastestInterval(1500)
            .setInterval(3000)
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationSettingsRequest.Builder settingsRequest = new LocationSettingsRequest.Builder();
    settingsRequest.addLocationRequest(request);

    SettingsClient client = LocationServices.getSettingsClient(getActivity());
    Task<LocationSettingsResponse> responseTask = client.checkLocationSettings
            (settingsRequest.build());

    responseTask.addOnSuccessListener(getActivity(), locationSettingsResponse ->
            locationScheduler());

    responseTask.addOnFailureListener(getActivity(), e -> {
        int statusCode = ((ApiException) e).getStatusCode();

        switch (statusCode){
            case CommonStatusCodes.RESOLUTION_REQUIRED:
                try {
                    ResolvableApiException apiException = ((ResolvableApiException)e);
                    apiException.startResolutionForResult(getActivity(), permissionCode);
                    Log.d(TAG, "Dialog displayed");
                }catch (IntentSender.SendIntentException sendIntentException){
                    Log.d(TAG, "Error displaying dialogBox", sendIntentException);
                }
                break;
            case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                Log.d(TAG, "Unable to turn on location service", e);

        }
    });
}
 
开发者ID:aumarbello,项目名称:WalkGraph,代码行数:43,代码来源:MapFragmentImpl.java

示例8: onCreate

import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    int SPLASH_TIME_OUT = 2000;

    ((GlobalValues) getApplication()).SetDonationKeyStatus();

    if (!((GlobalValues) getApplication()).DonationKeyFound()) { //if user is non pro then only check for offer key
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("promotion_offer", false);

        remoteConfig.setDefaults(hashMap);

        remoteConfig.setConfigSettings(new FirebaseRemoteConfigSettings.Builder()
                .setDeveloperModeEnabled(BuildConfig.DEBUG)
                .build());

        final Task<Void> fetch = remoteConfig.fetch(TimeUnit.HOURS.toSeconds(6));
        //if offer exist then activate pro features
        fetch.addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override
            public void onSuccess(Void aVoid) {
                remoteConfig.activateFetched();
                UpdateKey();
            }
        });
    }

    //init the key status here
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean isDark = preferences.getBoolean("DARK_THEME_KEY", false);
    if (isDark)
        setTheme(R.style.AppThemeDark);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash_screen);
    TextView textView = (TextView) findViewById(R.id.textView9);
    String s = "Version " + BuildConfig.VERSION_NAME;
    textView.setText(s);
    RelativeLayout Root = (RelativeLayout) findViewById(R.id.splash_screen);
    try {
        if (isDark) {
            Root.setBackgroundColor(ContextCompat.getColor(this, R.color.DarkcolorPrimaryDark));
        } else
            Root.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
    } catch (NullPointerException e) {
        Toast.makeText(getApplicationContext(), R.string.FatalError, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
        finish();
    }
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent intent = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(intent);
            finish();

        }
    }, SPLASH_TIME_OUT);
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:61,代码来源:SplashScreen.java


注:本文中的com.google.android.gms.tasks.Task.addOnSuccessListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。