Java Code Examples for io.flutter.plugin.common.MethodChannel#Result
The following examples show how to use
io.flutter.plugin.common.MethodChannel#Result .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdvCameraPlugin.java From adv_camera with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkForPermission(final MethodChannel.Result result) { Dexter.withActivity(activity) .withPermissions(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE) .withListener(new MultiplePermissionsListener() { @Override public void onPermissionsChecked(MultiplePermissionsReport report) { result.success(report.areAllPermissionsGranted()); } @Override public void onPermissionRationaleShouldBeShown(List<PermissionRequest> permissions, PermissionToken token) { token.continuePermissionRequest(); } }) .check(); }
Example 2
Source File: QrReaderView.java From flutter_qr_reader with MIT License | 6 votes |
@Override public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { switch (methodCall.method) { case "flashlight": _view.setTorchEnabled(!flashlight); flashlight = !flashlight; result.success(flashlight); break; case "startCamera": _view.startCamera(); break; case "stopCamera": _view.stopCamera(); break; } }
Example 3
Source File: LeancloudFunction.java From leancloud_flutter_plugin with MIT License | 6 votes |
/** * Setup region must be before call initialize function * * The call must be include args: * region --> NorthChina(0), EastChina(1), NorthAmerica(2) * REGION.NorthChina - this is default value * REGION.EastChina * REGION.NorthAmerica * * @param call MethodCall from LeancloudFlutterPlugin.onMethodCall function * @param result MethodChannel.Result from LeancloudFlutterPlugin.onMethodCall function */ static void setRegion(MethodCall call, MethodChannel.Result result) { int region_int = LeancloudArgsConverter.getIntValue(call, result, "region"); AVOSCloud.REGION region = AVOSCloud.REGION.NorthChina; switch (region_int) { case 0: // already assigned to this value break; case 1: region = AVOSCloud.REGION.EastChina; break; case 2: region = AVOSCloud.REGION.NorthAmerica; break; } AVOSCloud.setRegion(region); }
Example 4
Source File: AlbumLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * Fetch albums by id. * @param result * @param ids * @param sortType */ public void getAlbumsById(final MethodChannel.Result result, final List<String> ids, final AlbumSortType sortType){ String[] selectionArgs; String sortOrder = null; if (ids == null || ids.isEmpty()) { result.error("NO_ALBUM_IDS", "No Ids was provided", null); return; } if (ids.size() > 1){ selectionArgs = ids.toArray( new String[ ids.size() ]); if(sortType == AlbumSortType.CURRENT_IDs_ORDER) sortOrder = prepareIDsSortOrder( ids ); } else{ sortOrder = parseSortOrder(sortType); selectionArgs = new String[]{ ids.get(0) }; } createLoadTask(result, MediaStore.Audio.Albums._ID, selectionArgs, sortOrder, QUERY_TYPE_DEFAULT).execute(); }
Example 5
Source File: FlutterAMapSearchRegister.java From flutter_amap_plugin with MIT License | 5 votes |
@Override public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { if (methodCall.arguments instanceof String) { AMapRoutePlanningModel model = new Gson().fromJson(methodCall.arguments.toString(), AMapRoutePlanningModel.class); mRouteSearch = new RouteSearch(FlutterAmapPlugin.registrar.activity().getApplicationContext()); mRouteSearch.setRouteSearchListener(this); routePlanning(model); mShareSearch = new ShareSearch(FlutterAmapPlugin.registrar.activity().getApplicationContext()); mShareSearch.setOnShareSearchListener(this); routeShareUrl(model); } }
Example 6
Source File: CommonUtil.java From FlutterQiniucloudLivePlugin with Apache License 2.0 | 5 votes |
/** * 运行主线程返回错误结果执行 * * @param result 返回结果对象 * @param errorCode 错误码 * @param errorMessage 错误信息 * @param errorDetails 错误内容 */ public static void runMainThreadReturnError(final MethodChannel.Result result, final String errorCode, final String errorMessage, final Object errorDetails) { MAIN_HANDLER.post(new Runnable() { @Override public void run() { result.error(errorCode, errorMessage, errorDetails); } }); }
Example 7
Source File: SongLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * This method queries songs that appears on specific genre. * * @param result MethodChannel.Result object to send reply for dart. * @param genre Genre name that we want songs. * @param sortType SongSortType object to define sort type for data queried. */ public void getSongsFromGenre(final MethodChannel.Result result, final String genre, final SongSortType sortType){ createLoadTask(result, genre, null, parseSortOrder( sortType), QUERY_TYPE_GENRE_SONGS ) .execute(); }
Example 8
Source File: AlbumLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * Method used to query albums that appears in a specific genre * @param result MethodChannel.Result object to send reply for dart * @param genre String with genre name that you want find artist * @param sortType AlbumSortType object to define sort type for data queried. */ public void getAlbumFromGenre(final MethodChannel.Result result, final String genre, AlbumSortType sortType) { createLoadTask(result, genre, null, parseSortOrder(sortType), QUERY_TYPE_GENRE_ALBUM) .execute(); }
Example 9
Source File: LeancloudUser.java From leancloud_flutter_plugin with MIT License | 5 votes |
void signUp(MethodCall call, final MethodChannel.Result result) { JSONObject avQueryJson = LeancloudArgsConverter.getAVUserJsonObject(call, result); assert avQueryJson != null; String fieldsString = avQueryJson.getString("fields"); JSONObject fieldsJson = JSON.parseObject(fieldsString); AVUser user = new AVUser(); user.setUsername(fieldsJson.getString("username")); user.setPassword(fieldsJson.getString("password")); user.signUpInBackground().subscribe(new Observer<AVUser>() { @Override public void onSubscribe(Disposable disposable) {} @Override public void onNext(AVUser avUser) { result.success(avUser.toJSONObject().toJSONString()); } @Override public void onError(Throwable throwable) { AVException avException = new AVException(throwable); int code = avException.getCode(); result.error("leancloud-error", throwable.getMessage(), code); } @Override public void onComplete() {} }); }
Example 10
Source File: CommonUtil.java From FlutterQiniucloudLivePlugin with Apache License 2.0 | 5 votes |
/** * 运行主线程返回结果执行 * * @param result 返回结果对象 * @param param 返回参数 */ public static void runMainThreadReturn(final MethodChannel.Result result, final Object param) { Log.d(QiniucloudPushPlatformView.class.getName(), "run: 准备进入连麦线程"); MAIN_HANDLER.post(new Runnable() { @Override public void run() { Log.d(QiniucloudPushPlatformView.class.getName(), "run: 进入连麦线程"); result.success(param); } }); }
Example 11
Source File: AudioQueryDelegate.java From flutter_audio_query with MIT License | 5 votes |
/** * Method used to handle all method calls that is about playlist. * @param call Method call * @param result results input */ @Override public void playlistSourceHandler(MethodCall call, MethodChannel.Result result){ PlaylistLoader.PlayListMethodType type = PlaylistLoader.PlayListMethodType.values()[ (int) call.argument(PLAYLIST_METHOD_TYPE)]; switch (type){ case READ: if ( canIbeDependency(call, result)){ if (m_permissionManager.isPermissionGranted(Manifest.permission.READ_EXTERNAL_STORAGE) ){ clearPendencies(); handleReadOnlyMethods(call, result); } else m_permissionManager.askForPermission(Manifest.permission.READ_EXTERNAL_STORAGE, REQUEST_CODE_PERMISSION_READ_EXTERNAL); } else finishWithAlreadyActiveError(result); break; case WRITE: if ( canIbeDependency(call, result)){ if (m_permissionManager.isPermissionGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE) ){ clearPendencies(); handleWriteMethods(call, result); } else m_permissionManager.askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, REQUEST_CODE_PERMISSION_WRITE_EXTERNAL); } else finishWithAlreadyActiveError(result); break; default: result.notImplemented(); break; } }
Example 12
Source File: LanguageIdentifier.java From firebase_mlkit_language with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void handleEvent(String text, Map<String, Object> options, final MethodChannel.Result result) { if (identifier != null && !options.equals(lastOptions)){ identifier.close(); identifier = null; lastOptions = null; } if (identifier == null){ lastOptions = options; identifier = FirebaseNaturalLanguage.getInstance().getLanguageIdentification(parseOptions(lastOptions)); } identifier.identifyPossibleLanguages(text) .addOnSuccessListener( new OnSuccessListener<List<IdentifiedLanguage>>() { @Override public void onSuccess(List<IdentifiedLanguage> identifiedLanguages) { List<Map<String, Object>> labels = new ArrayList<>(identifiedLanguages.size()); for (IdentifiedLanguage identifiedLanguage : identifiedLanguages) { Map<String, Object> labelData = new HashMap<>(); String language = identifiedLanguage.getLanguageCode(); float confidence = identifiedLanguage.getConfidence(); labelData.put("confidence", (double) confidence); labelData.put("languageCode", language); labels.add(labelData); } result.success(labels); } }) .addOnFailureListener( new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { result.error("languageIdentifierError", e.getLocalizedMessage(), null); } }); }
Example 13
Source File: SongLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * This method queries for all songs that appears on specific album. * * @param result MethodChannel.Result object to send reply for dart. * @param albumId Album id that we want fetch songs * @param sortType SongSortType object to define sort type for data queried. */ public void getSongsFromAlbum(final MethodChannel.Result result, final String albumId, final SongSortType sortType){ // Log.i("MFBG", "Art: " + artist + " album: " + albumId); String selection = MediaStore.Audio.Media.ALBUM_ID + " =?"; createLoadTask( result, selection, new String[] {albumId}, parseSortOrder(sortType), QUERY_TYPE_ALBUM_SONGS).execute(); }
Example 14
Source File: PlaylistLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * Constructor for AbstractLoadTask. * * @param selection SQL selection param. WHERE clauses. * @param selectionArgs SQL Where clauses query values. * @param sortOrder Ordering. */ PlaylistLoadTask(final MethodChannel.Result result, final ContentResolver resolver, String selection, String[] selectionArgs, String sortOrder) { super(selection, selectionArgs, sortOrder); m_resolver = resolver; m_result = result; }
Example 15
Source File: QiniucloudPushPlatformView.java From FlutterQiniucloudLivePlugin with Apache License 2.0 | 5 votes |
/** * 更新美颜设置 */ private void updateFaceBeautySetting(MethodCall call, final MethodChannel.Result result) { double beautyLevel = CommonUtil.getParam(call, result, "beautyLevel"); double redden = CommonUtil.getParam(call, result, "redden"); double whiten = CommonUtil.getParam(call, result, "whiten"); manager.setVideoFilterType(CameraStreamingSetting.VIDEO_FILTER_TYPE.VIDEO_FILTER_BEAUTY); CameraStreamingSetting.FaceBeautySetting faceBeautySetting = new CameraStreamingSetting.FaceBeautySetting((float) beautyLevel, (float) whiten, (float) redden); cameraStreamingSetting.setFaceBeautySetting(faceBeautySetting); manager.updateFaceBeautySetting(faceBeautySetting); result.success(null); }
Example 16
Source File: PlaylistLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * This method query playlist using name as qyery parameter. * @param results MethodChannel.Result object to send reply for dart. * @param namedQuery query param. * @param sortType PlaylistSortType The type of sort desired. */ public void searchPlaylists(final MethodChannel.Result results, final String namedQuery, final PlaylistSortType sortType ){ String[] args = new String[] { namedQuery + "%"}; createLoadTask(results,MediaStore.Audio.Playlists.NAME + " like ?", args, parseSortType(sortType), QUERY_TYPE_DEFAULT ).execute(); }
Example 17
Source File: FlutterAMapComponentNavView.java From flutter_amap_plugin with MIT License | 5 votes |
@Override public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { if (methodCall.method.equals("startComponentNav")) { if (methodCall.arguments instanceof String) { Gson gson = new Gson(); Coordinate model; model = gson.fromJson(methodCall.arguments.toString(), Coordinate.class); latlon = model; initNav(); } } }
Example 18
Source File: QiniucloudPushPlatformView.java From FlutterQiniucloudLivePlugin with Apache License 2.0 | 4 votes |
/** * 设置连麦参数 */ private void setConferenceOptions(MethodCall call, final MethodChannel.Result result) { this.connectOptions = JSON.parseObject(CommonUtil.getParam(call, result, "conferenceOptions").toString(), RTCConferenceOptions.class); manager.setConferenceOptions(connectOptions); result.success(null); }
Example 19
Source File: FlutterUploaderPlugin.java From flutter_uploader with MIT License | 4 votes |
private void cancel(MethodCall call, MethodChannel.Result result) { String taskId = call.argument("task_id"); WorkManager.getInstance(register.context()).cancelWorkById(UUID.fromString(taskId)); result.success(null); }
Example 20
Source File: VoidCallBack.java From FlutterTencentImPlugin with Apache License 2.0 | 4 votes |
public VoidCallBack(MethodChannel.Result result) { this.result = result; }