TmfMiniSDK.startMiniApp(activity, appId, miniStartOptions);
TmfMiniSDK.startMiniApp(activiy, appId, MiniScene.LAUNCH_SCENE_MAIN_ENTRY, appVerType, options)
TmfMiniSDK.scan(activity);
TmfMiniSDK.getScanResult
获取二维码内容。@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data);//获取二维码结果 JSONObject scanResult = TmfMiniSDK.getScanResult(requestCode, data); }
'result'
字段中,需要提取 result 字段所对应的值,最终将使用这个值用于打开小程序。@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data);//获取二维码结果 JSONObject scanResult = TmfMiniSDK.getScanResult(requestCode, data);if (scanResult != null) { //提取result字段 String result = scanResult.optString("result"); if (!TextUtils.isEmpty(result)) { MiniStartLinkOptions options = new MiniStartLinkOptions();//利用result字段的值打开小程序 TmfMiniSDK.startMiniAppByLink(this, result, options); } } }
TmfMiniSDK.startMiniAppByScan(activity);
<string name="mini_sdk_intent_filter_scheme">your scheme</string>
参数名 | 类型 | 是否必填 | 说明 |
appId | String | 是 | 小程序id |
path | String | 否 | 小程序入口路径,需要进行URI编码 |
param | String | 否 | 传递给小程序的query,需要进行URI编码 |
SearchOptions searchOptions = new SearchOptions(keyword, firstCate, sencondaryCate);TmfMiniSDK.searchMiniApp(searchOptions, new MiniCallback<List<MiniApp>>() { @Override public void value(int code, String msg, List<MiniApp> data) { if (code == MiniCode.CODE_OK && data != null) { //搜索成功,小程序列表不为空 } else {//搜索失败或者小程序列表为空 } } });
SearchOptions searchOptions = new SearchOptions(keyword, firstCate, sencondaryCate);TmfMiniSDK.searchMiniApp(searchOptions, new MiniCallback<List<MiniApp>>() { @Override public void value(int code, String msg, List<MiniApp> data) { if (code == MiniCode.CODE_OK && data != null) { //搜索成功,小程序列表不为空MiniApp miniApp = data.get(0);//打开搜索结果中的第一个小程序 TmfMiniSDK.startMiniApp(this,miniApp.appId,MiniScene.LAUNCH_SCENE_SEARCH,MiniApp.TYPE_ONLINE,new MiniStartOptions()); } else {//搜索失败或者小程序列表为空 } } });
private ResultReceiver mResultReceiver = new ResultReceiver(new Handler()) {@Overrideprotected void onReceiveResult(int resultCode, Bundle resultData) {if (resultCode != MiniCode.CODE_OK) {String errMsg = resultData.getString("errMsg");Toast.makeText(mActivity, errMsg + resultCode, Toast.LENGTH_SHORT).show();}}};
本页内容是否解决了您的问题?