【发布时间】:2020-05-09 19:53:02
【问题描述】:
如何为我的热点生成一个二维码(我有一个文件,它使用随机 ssid、密码创建热点)
现在我想用zxing为它创建一个二维码。身份验证 = wap/wap2。我还遇到了 thissite 的 api,但它用于 html 文件<img src="https://qrcode.tec-it.com/API/QRCode?data=WIFI%3aT%3aWPA%3bS%3assid%3bP%3apaasword%3b%3b&backcolor=%23ffffff" />,如果可以从 java 文件中获取 ssid 和密码到这个 html 文件,那就太好了,很容易请分享一个 html 代码。或者我们可以使用 zxing 请帮我修改此代码以创建 Authentication= wap/wap2 的二维码。
请帮助我真的需要你的宝贵答案
package javaapplication27;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.nio.file.FileSystems;
import java.nio.file.Path;
public class NewClass1{
private static final String qcip = "C:\\Users\\lenovo\\Desktop\\kamal\\qrcode.png";
private static void generateQRCode(String text, int width, int height, String filePath)
throws Exception {
QRCodeWriter qcwobj = new QRCodeWriter();
BitMatrix bmobj = qcwobj.encode(text, BarcodeFormat.QR_CODE, width, height);
Path pobj = FileSystems.getDefault().getPath(filePath);
MatrixToImageWriter.writeToPath(bmobj, "PNG", pobj);
}
public static void main(String[] args) {
try {
generateQRCode("My Name Is Kamalpreet singh",1250, 1250, qcip);
} catch (Exception e) {
System.out.println("Could not generate QR Code" + e);
}
}
【问题讨论】:
-
[github.com/zxing/zxing/wiki/…伙计们请告诉我如何使用zxings来生成wifi配置二维码
标签: android html android-studio android-fragments zxing