io.flutter.plugin.common.MethodChannel Java Examples
The following examples show how to use
io.flutter.plugin.common.MethodChannel.
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: FlipperReduxInspectorPlugin.java From flutter_flipperkit with MIT License | 6 votes |
public void handleMethodCall(MethodCall call, MethodChannel.Result result) { if (call.method.endsWith("Report")) { final FlipperObject actionObject = new FlipperObject.Builder() .put("uniqueId", call.argument("uniqueId")) .put("actionType", call.argument("actionType")) .put("timeStamp", call.argument("timeStamp")) .put("payload", this.convertJsonToString(call, "payload")) .put("prevState", this.convertJsonToString(call, "prevState")) .put("nextState", this.convertJsonToString(call, "nextState")) .build(); this.send("newAction", actionObject); result.success(true); } }
Example #2
Source File: ArtistLoader.java From flutter_audio_query with MIT License | 6 votes |
/** * Fetch Artists by id. * @param result * @param ids * @param sortType */ public void getArtistsById(final MethodChannel.Result result, List<String> ids, ArtistSortType sortType){ String[] selectionArgs; String sortOrder = null; if (ids == null || ids.isEmpty()) { result.error("NO_ARTIST_IDS", "No Ids was provided", null); return; } if (ids.size() > 1){ selectionArgs = ids.toArray( new String[ ids.size() ]); if(sortType == ArtistSortType.CURRENT_IDs_ORDER) sortOrder = prepareIDsSortOrder( ids ); } else{ sortOrder = parseSortOrder(sortType); selectionArgs = new String[]{ ids.get(0) }; } createLoadTask(result, MediaStore.Audio.Artists._ID, selectionArgs, sortOrder, QUERY_TYPE_DEFAULT).execute(); }
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: VideoPlayer.java From media_player with MIT License | 5 votes |
VideoPlayer(Context context, EventChannel eventChannel, TextureRegistry.SurfaceTextureEntry textureEntry, MethodChannel.Result result) { Log.i(TAG, "VideoPlayer constuctor"); this.context = context; this.eventChannel = eventChannel; this.textureEntry = textureEntry; TrackSelector trackSelector = new DefaultTrackSelector(); exoPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector); setupVideoPlayer(eventChannel, textureEntry, result); }
Example #5
Source File: ArtistLoader.java From flutter_audio_query with MIT License | 5 votes |
ArtistLoadTask(final MethodChannel.Result result, final ContentResolver resolver, final String selection, final String[] selectionArgs, final String sortOrder, final int type) { super(selection, selectionArgs, sortOrder); m_resolver = resolver; m_result = result; m_queryType = type; }
Example #6
Source File: QiniucloudPushPlatformView.java From FlutterQiniucloudLivePlugin with Apache License 2.0 | 5 votes |
/** * 开始推流 */ private void startStreaming(MethodCall call, final MethodChannel.Result result) { String publishUrl = call.argument("publishUrl"); if (publishUrl != null) { try { streamingProfile.setPublishUrl(publishUrl); } catch (URISyntaxException e) { Log.e(TAG, "setStreamingProfile: setPublishUrl Error", e); result.error("0", e.toString(), e.getMessage()); return; } manager.setStreamingProfile(streamingProfile); } result.success(manager.startStreaming()); }
Example #7
Source File: QiniucloudConnectedPlayerPlatformView.java From FlutterQiniucloudLivePlugin with Apache License 2.0 | 5 votes |
/** * 配置连麦合流的参数(仅主播才配置,连麦观众不用) * 使用相对值来配置该窗口在合流画面中的位置和大小 */ private void setRelativeMixOverlayRect(MethodCall call, MethodChannel.Result result) { int x = CommonUtil.getParam(call, result, "x"); int y = CommonUtil.getParam(call, result, "y"); int w = CommonUtil.getParam(call, result, "w"); int h = CommonUtil.getParam(call, result, "h"); window.setRelativeMixOverlayRect(x, y, w, h); result.success(null); }
Example #8
Source File: AudioPlayerPlugin.java From flutter_exoplayer with MIT License | 5 votes |
@Override public void run() { final Map<String, AudioPlayer> audioPlayers = this.audioPlayers.get(); final MethodChannel channel = this.channel.get(); final Handler handler = this.handler.get(); final AudioPlayerPlugin audioPlayerPlugin = this.audioPlayerPlugin.get(); if (audioPlayers == null || channel == null || handler == null || audioPlayerPlugin == null) { if (audioPlayerPlugin != null) { audioPlayerPlugin.stopPositionUpdates(); } return; } boolean nonePlaying = true; for (AudioPlayer player : audioPlayers.values()) { if (!player.isPlaying()) { if (player.isPlayerCompleted()) { channel.invokeMethod("audio.onDurationChanged", buildArguments(player.getPlayerId(), player.getDuration())); } continue; } try { nonePlaying = false; channel.invokeMethod("audio.onDurationChanged", buildArguments(player.getPlayerId(), player.getDuration())); channel.invokeMethod("audio.onCurrentPositionChanged", buildArguments(player.getPlayerId(), player.getCurrentPosition())); } catch (UnsupportedOperationException e) { Log.e("AudioPlayerPlugin", "Error when updating position and duration"); } } if (nonePlaying) { audioPlayerPlugin.stopPositionUpdates(); } else { handler.postDelayed(this, 200); } }
Example #9
Source File: FlutterAMapNavView.java From flutter_amap_plugin with MIT License | 5 votes |
@Override public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { if (methodCall.method.equals("startNav")) { if (methodCall.arguments instanceof String) { Gson gson = new Gson(); Coordinate model = new Coordinate(); model = gson.fromJson(methodCall.arguments.toString(), Coordinate.class); latlon = model; initNav(); } } }
Example #10
Source File: FlutterAmapPlugin.java From flutter_amap_plugin with MIT License | 5 votes |
public static void registerWith(Registrar registrar) { FlutterAmapPlugin.registrar = registrar; final MethodChannel channel = new MethodChannel(registrar.messenger(), MAP_BASE_CHANNEL); channel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity())); final MethodChannel locChannel = new MethodChannel(registrar.messenger(), LOCATION_CHANNEL_NAME); locChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity())); FlutterAmapPlugin.locChannel = locChannel; final MethodChannel routeChannel = new MethodChannel(registrar.messenger(), SEARCH_ROUTE_CHANNEL_NAME); routeChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity())); FlutterAmapPlugin.routeChannel = routeChannel; final MethodChannel convertChannel = new MethodChannel(registrar.messenger(), SEARCH_CONVERT_CHANNEL_NAME); convertChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity())); FlutterAmapPlugin.convertChannel = convertChannel; final MethodChannel navChannel = new MethodChannel(registrar.messenger(), FlutterAMapNavView.NAV_CHANNEL_NAME); navChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity())); final FlutterAmapPlugin plugin = new FlutterAmapPlugin(root); registrar.platformViewRegistry().registerViewFactory(FlutterAMapView.MAP_CHANNEL_NAME, new FlutterAMapViewFactory(plugin.state, registrar)); registrar.platformViewRegistry().registerViewFactory(FlutterAMapNavView.NAV_CHANNEL_NAME, new FlutterAMapNavFactory(plugin.state, registrar)); }
Example #11
Source File: FlutterIsolatePlugin.java From flutter_isolate with MIT License | 5 votes |
private void setupChannel(BinaryMessenger messenger, Context context) { this.context = context; controlChannel = new MethodChannel(messenger, NAMESPACE + "/control"); queuedIsolates = new LinkedList<>(); activeIsolates = new HashMap<>(); controlChannel.setMethodCallHandler(this); }
Example #12
Source File: AudioQueryDelegate.java From flutter_audio_query with MIT License | 5 votes |
private boolean setPendingMethodAndCall(MethodCall call, MethodChannel.Result result){ //There is something that needs to be delivered... if (m_pendingResult != null) return false; m_pendingCall = call; m_pendingResult = result; return true; }
Example #13
Source File: LeancloudObject.java From leancloud_flutter_plugin with MIT License | 5 votes |
/** * Delete an AVObject * * @param call MethodCall from LeancloudFlutterPlugin.onMethodCall function * @param result MethodChannel.Result from LeancloudFlutterPlugin.onMethodCall function */ void delete(MethodCall call, final MethodChannel.Result result) { String avObject_string = LeancloudArgsConverter.getStringValue(call, result, "avObject"); AVObject avObject = this.convertStringToAVObject(avObject_string); if (avObject.getObjectId().isEmpty()) { result.error("Delete an Leancloud Object, it's objectId can not be empty!", null, null); } else { avObject.deleteInBackground().subscribe(new Observer<AVNull>() { @Override public void onSubscribe(Disposable disposable) { } @Override public void onNext(AVNull avNull) { result.success(true); } @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 #14
Source File: AudioQueryDelegate.java From flutter_audio_query with MIT License | 5 votes |
/** * Method used to handle all method calls that is about song data queries. * @param call Method call * @param result results input */ @Override public void songSourceHandler(MethodCall call, MethodChannel.Result result){ 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); }
Example #15
Source File: LeancloudArgsConverter.java From leancloud_flutter_plugin with MIT License | 5 votes |
static String getStringValue(MethodCall call, MethodChannel.Result result, String key) { Object arg = call.argument(key); if (arg == null) { result.error("missing-arg", "Arg '" + key + "' can't be null, set empty value. PLEASE FIX IT!", null); return ""; } else { return arg.toString(); } }
Example #16
Source File: LeancloudArgsConverter.java From leancloud_flutter_plugin with MIT License | 5 votes |
static int getIntValue(MethodCall call, MethodChannel.Result result, String key) { Object arg = call.argument(key); if (arg == null) { result.error("missing-arg", "Arg '" + key + "' can't be null, set 0 value. PLEASE FIX IT!", null); return 0; } else { return (int)arg; } }
Example #17
Source File: LeancloudArgsConverter.java From leancloud_flutter_plugin with MIT License | 5 votes |
static JSONObject getAVUserJsonObject(MethodCall call, MethodChannel.Result result) { String key = "avUser"; Object arg = call.argument(key); if (arg == null) { result.error("missing-arg", "Arg '" + key + "' can't be null, set empty value. PLEASE FIX IT!", null); return null; } else { return JSON.parseObject(arg.toString()); } }
Example #18
Source File: QiniucloudPushPlatformView.java From FlutterQiniucloudLivePlugin with Apache License 2.0 | 5 votes |
/** * 获取编码器输出的画面的高宽 */ private void getVideoEncodingSize(MethodCall call, final MethodChannel.Result result) { Map<String, Object> res = new HashMap<>(2, 1); res.put("width", connectOptions.getVideoEncodingWidth()); res.put("height", connectOptions.getVideoEncodingHeight()); result.success(JSON.toJSONString(res)); }
Example #19
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 #20
Source File: FlutterUploaderPlugin.java From flutter_uploader with MIT License | 5 votes |
public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME); final FlutterUploaderPlugin plugin = new FlutterUploaderPlugin(registrar, channel); channel.setMethodCallHandler(plugin); if (registrar.activity() != null) { registrar.activity().getApplication().registerActivityLifecycleCallbacks(plugin); } }
Example #21
Source File: SongLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * This method fetch songs with specified Ids. * @param result MethodChannel.Result object to send reply for dart. * @param ids Songs Ids. * @param sortType SongSortType object to define sort type for data queried. */ public void getSongsById(final MethodChannel.Result result, final List<String> ids, final SongSortType sortType){ String[] selectionArgs; String sortOrder = null; if (ids == null || ids.isEmpty()) { result.error("NO_SONG_IDS", "No Ids was provided", null); return; } if (ids.size() > 1){ selectionArgs = ids.toArray( new String[ ids.size() ]); if(sortType == SongSortType.CURRENT_IDs_ORDER) sortOrder = prepareIDsSongsSortOrder( ids ); } else{ sortOrder = parseSortOrder(sortType); selectionArgs = new String[]{ ids.get(0) }; } createLoadTask(result, MediaStore.Audio.Media._ID, selectionArgs, sortOrder, QUERY_TYPE_DEFAULT).execute(); }
Example #22
Source File: CommonUtil.java From FlutterTencentImPlugin with Apache License 2.0 | 5 votes |
/** * 通用方法,获得参数值,如未找到参数,则直接中断 * * @param methodCall 方法调用对象 * @param result 返回对象 * @param param 参数名 */ public static <T> T getParam(MethodCall methodCall, MethodChannel.Result result, String param) { T par = methodCall.argument(param); if (par == null) { result.error("Missing parameter", "Cannot find parameter `" + param + "` or `" + param + "` is null!", 5); throw new RuntimeException("Cannot find parameter `" + param + "` or `" + param + "` is null!"); } return par; }
Example #23
Source File: CommonUtil.java From FlutterTencentImPlugin 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 #24
Source File: ImeiPlugin.java From imei_plugin with MIT License | 5 votes |
/** * Plugin registration. * add Listener Request permission */ public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), "imei_plugin"); ImeiPlugin imeiPlugin = new ImeiPlugin(registrar.activity(), registrar.context().getContentResolver()); channel.setMethodCallHandler(imeiPlugin); registrar.addRequestPermissionsResultListener(imeiPlugin); }
Example #25
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 #26
Source File: AudioPlayerPlugin.java From flutter_exoplayer with MIT License | 5 votes |
private UpdateCallback(final Map<String, AudioPlayer> audioPlayers, final MethodChannel channel, final Handler handler, final AudioPlayerPlugin audioPlayerPlugin) { this.audioPlayers = new WeakReference<>(audioPlayers); this.channel = new WeakReference<>(channel); this.handler = new WeakReference<>(handler); this.audioPlayerPlugin = new WeakReference<>(audioPlayerPlugin); }
Example #27
Source File: GenreLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * This method makes a query that search genre by name with * nameQuery as query String. * @param results MethodChannel.Result object to send reply for dart * @param namedQuery The query param that will match genre name * @param sortType GenreSortType object to define sort type for data queried. */ public void searchGenres(final MethodChannel.Result results, final String namedQuery, final GenreSortType sortType ){ String[] args = new String[]{ namedQuery + "%"}; createLoadTask(results, GENRE_PROJECTION[0] + " like ?", args, parseSortOrder(sortType), QUERY_TYPE_DEFAULT).execute(); }
Example #28
Source File: SongLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * This method queries for songs from specific artist 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 artist Artist name that appears in album * @param sortType SongSortType object to define sort type for data queried. */ public void getSongsFromArtistAlbum(final MethodChannel.Result result, final String albumId, final String artist, final SongSortType sortType){ String selection = MediaStore.Audio.Media.ALBUM_ID + " =?" + " and " + MediaStore.Audio.Media.ARTIST + " =?"; createLoadTask( result, selection, new String[] {albumId, artist}, parseSortOrder(sortType), QUERY_TYPE_ALBUM_SONGS).execute(); }
Example #29
Source File: PlaylistLoader.java From flutter_audio_query with MIT License | 5 votes |
/** * This method is used to remove an entire playlist. * @param results MethodChannel.Result object to send reply for dart. * @param playlistId Playlist Id that will be removed. */ public void removePlaylist(final MethodChannel.Result results, final String playlistId){ ContentResolver resolver = getContentResolver(); try { int rows = resolver.delete(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, MediaStore.Audio.Playlists._ID + "=?", new String[]{playlistId}); updateResolver(); results.success(""); } catch (Exception ex){ results.error("PLAYLIST_DELETE_FAIL", "Was not possible remove playlist", null); } }
Example #30
Source File: FlutterBraintreeDropIn.java From FlutterBraintree with MIT License | 5 votes |
public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_braintree.drop_in"); FlutterBraintreeDropIn dropIn = new FlutterBraintreeDropIn(); dropIn.activity = registrar.activity(); registrar.addActivityResultListener(dropIn); channel.setMethodCallHandler(dropIn); }