本文整理汇总了Java中com.google.zxing.client.android.encode.QRCodeEncoder类的典型用法代码示例。如果您正苦于以下问题:Java QRCodeEncoder类的具体用法?Java QRCodeEncoder怎么用?Java QRCodeEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QRCodeEncoder类属于com.google.zxing.client.android.encode包,在下文中一共展示了QRCodeEncoder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getQRCodeBitmap
import com.google.zxing.client.android.encode.QRCodeEncoder; //导入依赖的package包/类
public static Bitmap getQRCodeBitmap(String address, Activity activity) {
final DisplayMetrics displaymetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
final int width = displaymetrics.widthPixels;
final Intent intent = new Intent(Intents.Encode.ACTION);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, address);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
try {
Log.i("", "Initializing QR: " + width);
final QRCodeEncoder encoder = new QRCodeEncoder(activity, intent, width, false);
return encoder.encodeAsBitmap();
} catch (Exception e) {
}
return null;
}
示例2: generateQRCode
import com.google.zxing.client.android.encode.QRCodeEncoder; //导入依赖的package包/类
private Bitmap generateQRCode(String uri) {
final float REG_RES = 2.0f;
Resources resources = getResources();
float scale = resources.getDisplayMetrics().density;
Bitmap bitmap = null;
int qrCodeDimension = (scale <= REG_RES) ? 440 : 880;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(uri, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimension);
try {
bitmap = qrCodeEncoder.encodeAsBitmap();
} catch (WriterException e) {
e.printStackTrace();
}
return bitmap;
}
示例3: generateQRCode
import com.google.zxing.client.android.encode.QRCodeEncoder; //导入依赖的package包/类
private Bitmap generateQRCode(String uri) {
Bitmap bitmap = null;
int qrCodeDimension = 280;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(uri, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimension);
try {
bitmap = qrCodeEncoder.encodeAsBitmap();
} catch (WriterException e) {
e.printStackTrace();
}
return bitmap;
}
示例4: generateQRCode
import com.google.zxing.client.android.encode.QRCodeEncoder; //导入依赖的package包/类
private Bitmap generateQRCode(String uri) {
Bitmap bitmap = null;
int qrCodeDimension = 150;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(uri, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimension);
try {
bitmap = qrCodeEncoder.encodeAsBitmap();
} catch (WriterException e) {
e.printStackTrace();
}
return bitmap;
}
示例5: generateQRCode
import com.google.zxing.client.android.encode.QRCodeEncoder; //导入依赖的package包/类
private Bitmap generateQRCode(String uri) {
Bitmap bitmap = null;
int qrCodeDimension = 380;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(uri, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimension);
try {
bitmap = qrCodeEncoder.encodeAsBitmap();
} catch (WriterException e) {
e.printStackTrace();
}
return bitmap;
}
示例6: share
import com.google.zxing.client.android.encode.QRCodeEncoder; //导入依赖的package包/类
/**
* Share the data from the intent.
*
* @param intent
*/
private void share(Intent intent, final Context context) {
// try to start server
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
mMimeType = type;
if (type.startsWith("text/x-vcard")) {
handleSendContactText(intent); // Handle text being sent
} else if (type.startsWith("text/")) {
handleSendRawText(intent); // Handle text being sent
} else if (type.startsWith("image/")) {
handleSendFile(intent); // Handle single image being sent
} else if (type.startsWith("audio/")) {
handleSendFile(intent); // Handle single audio being sent
} else if (type.startsWith("video/")) {
handleSendFile(intent); // Handle single video being sent
} else if (type.startsWith("application/")) {
handleSendFile(intent); // Handle single video being sent
}
NetworkUtils.WifiDetails wifiDetails = NetworkUtils
.getWifiDetails(mContext);
if (wifiDetails != null) {
// detect wifi network name
notifyOnServerWifiNetworkNameDetected(wifiDetails.ssid);
// security string
mRandomString = ("" + Math.abs(new Random().nextInt())).substring(0, 4);
mRealUrl = URL_BEGIN + wifiDetails.ipAddress + ":"
+ ShAIReConstants.SERVER_PORT + "/" + mRandomString;
// generate shorten url
UrlShortener.getInstance(mContext).shortenUrlonTinyUrl(mRealUrl,
this);
// generate QR code
try {
Intent intentText = new Intent();
intentText.setAction(Intents.Encode.ACTION);
intentText.putExtra(Intents.Encode.FORMAT,
BarcodeFormat.QR_CODE.toString());
intentText
.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intentText.putExtra(Intents.Encode.DATA, mRealUrl);
mQrCodeEncoder = new QRCodeEncoder(mContext, intentText,
500, false);
Bitmap qrCode = mQrCodeEncoder.encodeAsBitmap();
notifyServerUrlQRCodeGenerated(qrCode);
} catch (WriterException e) {
notifyOnServerUrlQRCodeGeneratioFailed();
}
} else {
notifyError(mContext
.getString(R.string.please_make_sure_your_wifi_is_actvivated));
}
} else {
notifyError(mContext.getString(R.string.you_cant_share_this));
}
}