本文整理汇总了Java中com.google.zxing.client.android.Contents类的典型用法代码示例。如果您正苦于以下问题:Java Contents类的具体用法?Java Contents怎么用?Java Contents使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Contents类属于com.google.zxing.client.android包,在下文中一共展示了Contents类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getQRCodeBitmap
import com.google.zxing.client.android.Contents; //导入依赖的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.Contents; //导入依赖的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: addContact
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
final void addContact(String[] names, String[] phoneNumbers, String[] emails, String note,
String address, String org, String title) {
// Only use the first name in the array, if present.
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, Contacts.CONTENT_URI);
intent.setType(Contacts.People.CONTENT_ITEM_TYPE);
putExtra(intent, Contacts.Intents.Insert.NAME, names != null ? names[0] : null);
int phoneCount = Math.min(phoneNumbers != null ? phoneNumbers.length : 0,
Contents.PHONE_KEYS.length);
for (int x = 0; x < phoneCount; x++) {
putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[x]);
}
int emailCount = Math.min(emails != null ? emails.length : 0, Contents.EMAIL_KEYS.length);
for (int x = 0; x < emailCount; x++) {
putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]);
}
putExtra(intent, Contacts.Intents.Insert.NOTES, note);
putExtra(intent, Contacts.Intents.Insert.POSTAL, address);
putExtra(intent, Contacts.Intents.Insert.COMPANY, org);
putExtra(intent, Contacts.Intents.Insert.JOB_TITLE, title);
launchIntent(intent);
}
示例4: onCreateOptionsMenu
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.encode, menu);
boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
MenuItem encodeItem = menu.findItem(R.id.menu_encode);
encodeItem.setTitle(encodeNameResource);
Intent intent = getIntent();
if (intent != null) {
String type = intent.getStringExtra(Intents.Encode.TYPE);
encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
}
return super.onCreateOptionsMenu(menu);
}
示例5: launchSearch
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
private void launchSearch(String text) {
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
示例6: showTextAsBarcode
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
private void showTextAsBarcode(String text) {
Log.i(TAG, "Showing text as barcode: " + text);
if (text == null) {
return; // Show error?
}
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
示例7: launchSearch
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
private void launchSearch(String text) {
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
示例8: showTextAsBarcode
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
private void showTextAsBarcode(String text) {
Log.i(TAG, "Showing text as barcode: " + text);
if (text == null) {
return; // Show error?
}
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
示例9: onCreateOptionsMenu
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.encode, menu);
boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard;
MenuItem encodeItem = menu.findItem(R.id.menu_encode);
encodeItem.setTitle(encodeNameResource);
Intent intent = getIntent();
if (intent != null) {
String type = intent.getStringExtra(Intents.Encode.TYPE);
encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
}
return super.onCreateOptionsMenu(menu);
}
示例10: onCreateOptionsMenu
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(fakeR.getId("menu", "encode"), menu);
boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard();
int encodeNameResource = useVcard ? fakeR.getId("string", "menu_encode_mecard") : fakeR.getId("string", "menu_encode_vcard");
MenuItem encodeItem = menu.findItem(fakeR.getId("id", "menu_encode"));
encodeItem.setTitle(encodeNameResource);
Intent intent = getIntent();
if (intent != null) {
String type = intent.getStringExtra(Intents.Encode.TYPE);
encodeItem.setVisible(Contents.Type.CONTACT.equals(type));
}
return super.onCreateOptionsMenu(menu);
}
示例11: launchSearch
import com.google.zxing.client.android.Contents; //导入依赖的package包/类
private void launchSearch(String text) {
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}