android开机自动打开微信小程序,Android APP内直接调起微信小程序

Android应用一般通过点击链接,再调起微信小程序,现在需要在Android应用内,通过一个点击事件,直接进入微信小程序内。

1.准备一个注册了微信平台的应用。

2.写好你的小程序,在微信开发平台用你的应用关联你的小程序。

3.拿出你的AppId和小程序原始Id

4.写代码

4.1先加微信开发者包

implementation 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.3.1'

activity代码

String appId = "AppId"; // 填应用AppId

IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);

WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();

req.userName = "小程序原始id"; // 填小程序原始id

req.path = "拉起小程序页面的可带参路径"; //拉起小程序页面的可带参路径,不填默认拉起小程序首页

req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;// 可选打开 开发版,体验版和正式版

api.sendReq(req);

它还有一个回调方法,建一个文件夹(/wxapi)下建一个类WXEntryActivity,文件夹和类名必须一致

abe336ca2fed

image.png

该代码搜索不到蓝牙设备,一直在显示正在搜索中<template> <view> <view class="uni-list"> <!-- 隐藏画布,用于标签绘制 --> <canvas :id="canvasId" :canvas-id="canvasId" type="2d" :style="{ width: labelWidth + 'px', height: labelHeight + 'px' }" style="position: fixed; left: -999999rpx; top: -999999rpx" /> <!-- 打印机列表 --> <view class="uni-list-cell"> <view class="uni-list-cell-left">打印机:</view> <view class="uni-list-cell-db"> <picker :value="deviceIndex" :range="deviceList" @change="onDeviceChanged" range-key="name"> <view class="uni-input">{{ deviceList[deviceIndex].name }}</view> </picker> </view> </view> </view> <view class="uni-padding-wrap uni-common-mt"> <!-- 设备搜索 --> <button type="primary" @click="startDiscovery">开始搜索打印机</button> <button type="primary" @click="stopDiscovery">停止搜索打印机</button> <!-- 链接打印机 --> <button type="primary" @click="openPrinter">打开打印机</button> <button type="primary" @click="closePrinter">关闭打印机</button> <!-- 标签编辑及打印 --> <button type="primary" plain="true" @click="onPrintTest">打印测试</button> </view> <view style="text-align: center; padding: 10px"> <view style="margin: 10px; border: solid lightgray 1px"> <image v-for="item in previewList" :src="item.value" :key="item.key" class="image" mode="widthFix" style="margin: 10rpx; border: dashed lightgray 1px" /> </view> </view> </view> </template> <script> import { LPAPIFactory, LPA_Result, LPAUtils } from "@/uni_modules/dothan-lpapi-ble/js_sdk/index.js"; export default { data() { return { canvasId: "lpapi-ble-uni1", labelWidth: 960, labelHeight: 960, deviceList: [{ name: "未检测到打印机" }], deviceIndex: 0, isAppPlus: false, isWeiXin: false, isLark: false, isAlipay: false, isDingTalk: false, previewList: [], threshold: 128, }; }, onLoad() { console.log("========== onLoad =========="); // #ifdef APP-PLUS this.isAppPlus = true; // #endif // #ifdef MP-
最新发布
03-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值