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


Java ResultCallback类代码示例

本文整理汇总了Java中com.google.android.gms.common.api.ResultCallback的典型用法代码示例。如果您正苦于以下问题:Java ResultCallback类的具体用法?Java ResultCallback怎么用?Java ResultCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResultCallback类属于com.google.android.gms.common.api包,在下文中一共展示了ResultCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onGoogleApiClientReady

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
protected void onGoogleApiClientReady(final GoogleApiClient apiClient, final Observer<? super Status> observer) {
    // this throws SecurityException if permissions are bad or mock locations are not enabled,
    // which is passed to observer's onError by BaseObservable
    LocationServices.FusedLocationApi.setMockMode(apiClient, true)
            .setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(Status status) {
                    if (status.isSuccess()) {
                        startLocationMocking(apiClient, observer);
                    } else {
                        observer.onError(new StatusException(status));
                    }
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:MockLocationObservable.java

示例2: onGoogleApiClientReady

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
protected void onGoogleApiClientReady(GoogleApiClient apiClient, final Observer<? super Status> observer) {
    LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, locationRequest, intent)
            .setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(Status status) {
                    if (!status.isSuccess()) {
                        observer.onError(new StatusException(status));
                    } else {
                        observer.onNext(status);
                        observer.onCompleted();
                    }
                }
            });

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:AddLocationIntentUpdatesObservable.java

示例3: call

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
public void call(final Subscriber<? super T> subscriber) {
    result.setResultCallback(new ResultCallback<T>() {
        @Override
        public void onResult(T t) {
            subscriber.onNext(t);
            complete = true;
            subscriber.onCompleted();
        }
    });
    subscriber.add(Subscriptions.create(new Action0() {
        @Override
        public void call() {
            if (!complete) {
                result.cancel();
            }
        }
    }));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:PendingResultObservable.java

示例4: play

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
/**
 * Resumes the playback from where it was left (can be the beginning).
 *
 * @param customData Optional {@link JSONObject} data to be passed to the cast device
 * @throws NoConnectionException
 * @throws TransientNetworkDisconnectionException
 */
public void play(JSONObject customData) throws
        TransientNetworkDisconnectionException, NoConnectionException {
    LOGD(TAG, "play(customData)");
    checkConnectivity();
    if (mRemoteMediaPlayer == null) {
        LOGE(TAG, "Trying to play a video with no active media session");
        throw new NoConnectionException();
    }
    mRemoteMediaPlayer.play(mApiClient, customData)
            .setResultCallback(new ResultCallback<MediaChannelResult>() {

                @Override
                public void onResult(MediaChannelResult result) {
                    if (!result.getStatus().isSuccess()) {
                        onFailed(R.string.ccl_failed_to_play,
                                result.getStatus().getStatusCode());
                    }
                }

            });
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:29,代码来源:VideoCastManager.java

示例5: refreshPlacesData

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
public void refreshPlacesData(){
    Uri uri = PlacesContract.PlaceEntry.CONTENT_URI;
    Cursor dataCursor = getContentResolver().query(uri,
            null,
            null,
            null,null,null);
    if (dataCursor==null||dataCursor.getCount()==0) return;
    List<String> placeIds = new ArrayList<String>();
    while (dataCursor.moveToNext()){
        placeIds.add(dataCursor.getString(dataCursor.getColumnIndex(PlacesContract.PlaceEntry.COLUMN_PLACE_ID)));
    }
    PendingResult<PlaceBuffer> placeBufferPendingResult = Places.GeoDataApi.getPlaceById(mClient,
            placeIds.toArray(new String[placeIds.size()]));
    placeBufferPendingResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
        @Override
        public void onResult(@NonNull PlaceBuffer places) {
            mAdapter.swapPlaces(places);
            mGeofencing.updateGeofencesList(places);
            if (mIsEnabled) mGeofencing.registerAllGeofences();
        }
    });
}
 
开发者ID:samagra14,项目名称:Shush,代码行数:23,代码来源:MainActivity.java

示例6: onResult

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@Override
public void onResult(@NonNull DriveApi.DriveContentsResult driveContentsResult) {
    OutputStream outputStream = driveContentsResult.getDriveContents().getOutputStream();
    try {
        outputStream.write("".getBytes());
        driveContentsResult.getDriveContents().commit(mGoogleApiClient, null).setResultCallback(new ResultCallback<Status>() {
            @Override
            public void onResult(@NonNull Status status) {
                if (!status.isSuccess())
                    Toast.makeText(getApplicationContext(), getString(R.string.drive_fail_save_data), Toast.LENGTH_LONG).show();
            }
        });
    } catch (IOException e) {
        Toast.makeText(getApplicationContext(), getString(R.string.drive_fail_save_data), Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:JeanBarriere,项目名称:Note,代码行数:17,代码来源:MainActivity.java

示例7: signOut

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
public void signOut() {
	// Firebase sign out
	mAuth.signOut();

	// Google sign out
	if (mGoogleApiClient.isConnected()) {
		Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
		new ResultCallback<Status>() {

			@Override
			public void onResult(@NonNull Status status) {
				// update user details.
			}
		});
	}
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:17,代码来源:GoogleSignIn.java

示例8: setTextTrackStyle

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
/**
 * Sets or updates the style of the Text Track.
 */
public void setTextTrackStyle(TextTrackStyle style) {
    mRemoteMediaPlayer.setTextTrackStyle(mApiClient, style)
            .setResultCallback(new ResultCallback<MediaChannelResult>() {
                @Override
                public void onResult(MediaChannelResult result) {
                    if (!result.getStatus().isSuccess()) {
                        onFailed(R.string.ccl_failed_to_set_track_style,
                                result.getStatus().getStatusCode());
                    }
                }
            });
    for (VideoCastConsumer consumer : mVideoConsumers) {
        try {
            consumer.onTextTrackStyleChanged(style);
        } catch (Exception e) {
            LOGE(TAG, "onTextTrackStyleChanged(): Failed to inform " + consumer, e);
        }
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:23,代码来源:VideoCastManager.java

示例9: signOut

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
protected void signOut(GoogleApiClient googleApiClient){
    mAuth.signOut();

    Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(new ResultCallback<Status>() {
        @Override
        public void onResult(@NonNull Status status) {
            Toast toast = Toast.makeText(AuthBaseActivity.this,
                    mResources.getString(R.string.sign_out_text),
                    Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 100);
            toast.show();

            Intent i = new Intent(AuthBaseActivity.this, SignInActivity.class);
            AuthBaseActivity.this.startActivity(i);
            AuthBaseActivity.this.finish();
        }
    });
}
 
开发者ID:AviralGarg1993,项目名称:VR-One,代码行数:19,代码来源:AuthBaseActivity.java

示例10: startMatch

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
public void startMatch(TurnBasedMatch match) {
	System.out.println("Started match");

	mTurnData = new GameModelWrapper();

	mMatch = match;

	String playerId = Games.Players.getCurrentPlayerId(gameHelper.getApiClient());
	String myParticipantId = mMatch.getParticipantId(playerId);

	Games.TurnBasedMultiplayer.takeTurn(gameHelper.getApiClient(), match.getMatchId(),
			mTurnData.convertToByteArray(), myParticipantId).setResultCallback(
			new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
				@Override
				public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
					processResult(result);
				}
			});
}
 
开发者ID:antonioalmeida,项目名称:retro-reversi,代码行数:20,代码来源:AndroidLauncher.java

示例11: setActiveTrackIds

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
/**
 * Sets the active tracks for the currently loaded media.
 */
public void setActiveTrackIds(long[] trackIds) {
    if (mRemoteMediaPlayer == null || mRemoteMediaPlayer.getMediaInfo() == null) {
        return;
    }
    mRemoteMediaPlayer.setActiveMediaTracks(mApiClient, trackIds)
            .setResultCallback(new ResultCallback<MediaChannelResult>() {
                @Override
                public void onResult(MediaChannelResult mediaChannelResult) {
                    LOGD(TAG, "Setting track result was successful? "
                            + mediaChannelResult.getStatus().isSuccess());
                    if (!mediaChannelResult.getStatus().isSuccess()) {
                        LOGD(TAG, "Failed since: " + mediaChannelResult.getStatus()
                                + " and status code:" + mediaChannelResult.getStatus()
                                .getStatusCode());
                    }
                }
            });
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:22,代码来源:VideoCastManager.java

示例12: callPlaceDetectionApi

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
            }
            likelyPlaces.release();
        }
    });
}
 
开发者ID:addy-org,项目名称:Addy-Android,代码行数:17,代码来源:PlacesAPIActivity.java

示例13: callPlaceDetectionApi

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
private void callPlaceDetectionApi() throws SecurityException {
    PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.i(LOG_TAG, String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()));
                display.setText(placeLikelihood.getPlace().getAddress().toString());
                messageSending(placeLikelihood.getPlace().getAddress().toString());
                break;
            }
            likelyPlaces.release();
        }
    });
}
 
开发者ID:Pritom14,项目名称:Gps,代码行数:20,代码来源:Gps4Activity.java

示例14: startGeofenceMonitoring

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
public void startGeofenceMonitoring() {
	if (googleApiClient.isConnected()) {
		for (com.team_htbr.a1617proj1bloeddonatie_app.Location location: locationsList) {
			geofences.add(new Geofence.Builder()
				.setRequestId(location.getName())
				.setCircularRegion(location.getLat(), location.getLng(), 1000)
				.setExpirationDuration(Geofence.NEVER_EXPIRE)
				.setNotificationResponsiveness(5000)
				.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER)
				.build());
		}

		GeofencingRequest geofencingRequest = new GeofencingRequest.Builder()
			.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER)
			.addGeofences(geofences).build();


		Intent intent = new Intent(this, GeofenceService.class);
		PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

		if (!googleApiClient.isConnected()) {
			Log.d(TAG, "no connection");
		} else {
			if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
				return;
			}
			LocationServices.GeofencingApi.addGeofences(googleApiClient, geofencingRequest, pendingIntent)
				.setResultCallback(new ResultCallback<Status>() {
					@Override
					public void onResult(@NonNull Status status) {
						if (status.isSuccess()) {
							Log.d(TAG, "succesful add");
						} else {
							Log.d(TAG, "Failed to add");
						}
					}
				});
		}
	}
}
 
开发者ID:team-htbr,项目名称:1617PROJ1Bloeddonatie-app,代码行数:41,代码来源:MainActivity.java

示例15: findAllWearDevices

import com.google.android.gms.common.api.ResultCallback; //导入依赖的package包/类
@SuppressLint("LongLogTag")
private void findAllWearDevices() {
    Log.d(TAG, "findAllWearDevices()");

    PendingResult<NodeApi.GetConnectedNodesResult> pendingResult =
            Wearable.NodeApi.getConnectedNodes(mGoogleApiClient);

    pendingResult.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
        @Override
        public void onResult(@NonNull NodeApi.GetConnectedNodesResult getConnectedNodesResult) {

            if (getConnectedNodesResult.getStatus().isSuccess()) {
                mAllConnectedNodes = getConnectedNodesResult.getNodes();
                verifyNodeAndUpdateUI();
                Log.e("Connected Nodes", "->"+mAllConnectedNodes.toString());
                findWearDevicesWithApp();

            } else {
                Log.d(TAG, "Failed NodeApi: " + getConnectedNodesResult.getStatus());
            }
        }
    });
}
 
开发者ID:squareboat,项目名称:Excuser,代码行数:24,代码来源:DeviceWearConnectionFragment.java


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