uniapp打开第三方app,然后给传参过去
参考链接:uniapp唤醒uniapp并传递参数,vue唤醒第三方应用并传递参数.参考链接:Runtime模块管理运行环境.<template><view class="content"><button type="default" @click="jsCallNativeActivity()">点击打开demo</button></view&
·
参考链接:uniapp唤醒uniapp并传递参数,vue唤醒第三方应用并传递参数.
- uniapp如何打开app,传递的值的
<template>
<view class="content">
<button type="default" @click="jsCallNativeActivity()">点击打开demo</button>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
jsCallNativeActivity() {
let _this = this;
// 判断平台
if (plus.os.name == 'Android') {
plus.runtime.launchApplication({
//这里输入包名
pname: 'com.exaample.demo',
//传值
extra: {
key: 123
}
},
function(e) {
console.log('Open system default browser failed: ' + e.message);
}
);
} else if (plus.os.name == 'iOS') {
plus.runtime.launchApplication({
action: 'taobao://'
}, function(e) {
console.log('Open system default browser failed: ' + e.message);
});
}
}
}
}
</script>
- 下面是安卓app 页面里如何接收的
package com.example.demo;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.tv);
Intent intent = getIntent();
StringBuffer sb = new StringBuffer();
Bundle bundle = intent.getExtras();
if (null == bundle) {
textView.setText("bundle为空");
return;
}
for (String key : bundle.keySet()) {
sb.append(" key = ").append(key).append(" , value = ").append(bundle.get(key)).append(" ; ");
}
textView.setText(sb.toString());
}
}
更多推荐
已为社区贡献7条内容
所有评论(0)