當前位置: 首頁>>代碼示例>>Java>>正文


Java QRCodeEncoder類代碼示例

本文整理匯總了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;
}
 
開發者ID:bushidowallet,項目名稱:bushido-android-app,代碼行數:18,代碼來源:QRCodeUtil.java

示例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;
    }
 
開發者ID:10xEngineer,項目名稱:My-Wallet-Android,代碼行數:20,代碼來源:QRActivity.java

示例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;
    }
 
開發者ID:10xEngineer,項目名稱:My-Wallet-Android,代碼行數:16,代碼來源:ReceiveFragment.java

示例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;
    }
 
開發者ID:10xEngineer,項目名稱:My-Wallet-Android,代碼行數:16,代碼來源:SendFragment.java

示例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;
    }
 
開發者ID:10xEngineer,項目名稱:My-Wallet-Android,代碼行數:16,代碼來源:BalanceFragment.java

示例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));
    }
}
 
開發者ID:guiguito,項目名稱:AIRShare,代碼行數:63,代碼來源:ShAIReHttpServer.java


注:本文中的com.google.zxing.client.android.encode.QRCodeEncoder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。