android原生插件,创建module
public class AmapWXModule extends WXSDKEngine.DestroyableModule {
@JSMethod(uiThread = true)
public void startNaviGao(JSONObject options) {
if (mWXSDKInstance.getContext() instanceof Activity) {
StringBuffer stringBuffer = new StringBuffer("amapuri://route/plan/");
String sid = options.getString("sid");
String slat = options.getString("slat");
String slon = options.getString("slon");
String sname = options.getString("sname");
String did = options.getString("did");
String dlat = options.getString("dlat");
String dlon = options.getString("dlon");
String dname = options.getString("dname");
String dev = options.getString("dev");
String t = options.getString("t");
stringBuffer.append("?sid=").append(sid)
.append("&slat=").append(slat)
.append("&slon=").append(slon)
.append("&sname=").append(sname)
.append("&did=").append(did)
.append("&dlat=").append(dlat)
.append("&dlon=").append(dlon)
.append("&dname=").append(dname)
.append("&dev=").append(dev)
.append("&t=").append(t);
Intent intent = new Intent("android.intent.action.VIEW", android.net.Uri.parse(stringBuffer.toString()));
intent.setPackage("com.autonavi.minimap");
mWXSDKInstance.getContext().startActivity(intent);
}
}
@Override
public void destroy() {
}
}
dcloud_uniplugins.json添加插件
{
"type": "module",
"name": "Amap",
"class": "com.demo.AmapWXModule"
}
uniapp使用
const modal = uni.requireNativePlugin('modal');
const amap = uni.requireNativePlugin('Amap');
methods: {
AppAmap()
{
amap.startNaviGao({sid:'A',slat:'36.7025585',slon:'116.8766784700',sname:'开始'
,did:'B',dlat:'36.6494152900',dlon:'117.1224975600',dname:'结束',dev:'1',t:'0'});
},
}
android原生项目app下的build.gradle中添加新增的 module
// 添加uni-app插件
implementation project(':amaplib')
3 个评论
要回复文章请先登录或注册
1***@qq.com
y***@163.com (作者)
y***@163.com (作者)