本文整理汇总了Java中com.google.zxing.client.android.Intents类的典型用法代码示例。如果您正苦于以下问题:Java Intents类的具体用法?Java Intents怎么用?Java Intents使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Intents类属于com.google.zxing.client.android包,在下文中一共展示了Intents类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResult
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Constants.QR_ACTIVITY_RESULT_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
final String scanContent = data.getStringExtra(Intents.Scan.RESULT);
try {
BitcoinURI bitcoinURI = new BitcoinURI(scanContent);
if (bitcoinURI.getAddress() != null) {
addressEditText.setText(bitcoinURI.getAddress().toString());
return;
}
} catch (BitcoinURIParseException e) {
Log.w(TAG, "Could not parse scanned content: '" + scanContent + "'", e);
}
// set to scanned content if no address detected
addressEditText.setText(scanContent);
}
}
}
示例2: registerMediaStoreIntentHandler
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
/**
* Register a handler in the package manager for a image capture intent
*/
private void registerMediaStoreIntentHandler()
{
// Add something that will 'handle' the media capture intent
RobolectricPackageManager packageManager = shadowOf(RuntimeEnvironment.application.getPackageManager());
ResolveInfo info = new ResolveInfo();
info.isDefault = true;
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.packageName = "does.not.matter";
info.activityInfo = new ActivityInfo();
info.activityInfo.applicationInfo = applicationInfo;
info.activityInfo.name = "DoesNotMatter";
Intent intent = new Intent(Intents.Scan.ACTION);
packageManager.addResolveInfoForIntent(intent, info);
}
示例3: onActivityResult
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IntentIntegrator.REQUEST_CODE
&& resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
String commands = extras.getString(
Intents.Scan.RESULT);
JSONObject jsonCommands = null;
try {
jsonCommands = new JSONObject(commands);
if (startOrEnd == 's') {
this.startStation = jsonCommands.getInt("startStation");
((TextView) findViewById(R.id.commandOutTextView)).setText(commands);
} else {
this.endStation = jsonCommands.getInt("endStation");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
示例4: onCreate
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Make sure that expired cookies are removed on launch.
CookieSyncManager.createInstance(this);
CookieManager.getInstance().removeExpiredCookie();
Intent intent = getIntent();
if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
finish();
return;
}
isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
if (LocaleManager.isBookSearchUrl(isbn)) {
setTitle(getString(R.string.sbc_name));
} else {
setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
}
setContentView(R.layout.search_book_contents);
queryTextView = (EditText) findViewById(R.id.query_text_view);
String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
if (initialQuery != null && !initialQuery.isEmpty()) {
// Populate the search box but don't trigger the search
queryTextView.setText(initialQuery);
}
queryTextView.setOnKeyListener(keyListener);
queryButton = findViewById(R.id.query_button);
queryButton.setOnClickListener(buttonListener);
resultListView = (ListView) findViewById(R.id.result_list_view);
LayoutInflater factory = LayoutInflater.from(this);
headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
resultListView, false);
resultListView.addHeaderView(headerView);
}
示例5: onCreate
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Intent intent = getIntent();
if (intent == null) {
finish();
} else {
String action = intent.getAction();
if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) {
setContentView(R.layout.encode);
} else {
finish();
}
}
}
示例6: onCreateOptionsMenu
import com.google.zxing.client.android.Intents; //导入依赖的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);
}
示例7: QRCodeEncoder
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException {
this.activity = activity;
this.dimension = dimension;
this.useVCard = useVCard;
String action = intent.getAction();
if (action.equals(Intents.Encode.ACTION)) {
encodeContentsFromZXingIntent(intent);
} else if (action.equals(Intent.ACTION_SEND)) {
encodeContentsFromShareIntent(intent);
}
}
示例8: encodeContentsFromZXingIntent
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
private boolean encodeContentsFromZXingIntent(Intent intent) {
// Default to QR_CODE if no format given.
String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
format = null;
if (formatString != null) {
try {
format = BarcodeFormat.valueOf(formatString);
} catch (IllegalArgumentException iae) {
// Ignore it then
}
}
if (format == null || format == BarcodeFormat.QR_CODE) {
String type = intent.getStringExtra(Intents.Encode.TYPE);
if (type == null || type.isEmpty()) {
return false;
}
this.format = BarcodeFormat.QR_CODE;
encodeQRCodeContents(intent, type);
} else {
String data = intent.getStringExtra(Intents.Encode.DATA);
if (data != null && !data.isEmpty()) {
contents = data;
displayContents = data;
title = activity.getString(R.string.contents_text);
}
}
return contents != null && !contents.isEmpty();
}
示例9: onActivityResult
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == IntentIntegrator.REQUEST_CODE) {
if (resultCode == RESULT_OK) {
final String contents = data.getStringExtra(Intents.Scan.RESULT);
mInput.postDelayed(new Runnable() {
@Override
public void run() {
mInput.setText(contents);
if (getContext() != null) {
Toast.makeText(getContext(), R.string.decoded, Toast.LENGTH_SHORT).show();
}
}
}, 200);
}
} else if (requestCode == REQUEST_PICK_IMAGE) {
if (resultCode == RESULT_OK) {
if (mDecodeImageTask != null && !mDecodeImageTask.isCancelled()) {
mDecodeImageTask.cancel(true);
}
mDecodeImageTask = new DecodeImageTask(getContext().getApplicationContext(), mInput);
mDecodeImageTask.execute(data.getData());
}
}
}
示例10: launchSearch
import com.google.zxing.client.android.Intents; //导入依赖的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);
}
示例11: showTextAsBarcode
import com.google.zxing.client.android.Intents; //导入依赖的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);
}
示例12: searchBookContents
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
final void searchBookContents(String isbnOrUrl) {
Intent intent = new Intent(Intents.SearchBookContents.ACTION);
intent.setClassName(activity, SearchBookContentsActivity.class.getName());
putExtra(intent, Intents.SearchBookContents.ISBN, isbnOrUrl);
launchIntent(intent);
}
示例13: onListItemClick
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
if (adapter.getItem(position).getResult() != null) {
Intent intent = new Intent(this, CaptureActivity.class);
intent.putExtra(Intents.History.ITEM_NUMBER, position);
setResult(Activity.RESULT_OK, intent);
finish();
}
}
示例14: addHistoryItem
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
public void addHistoryItem(Result result, ResultHandler handler) {
// Do not save this item to the history if the preference is turned off, or the contents are
// considered secure.
if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
handler.areContentsSecure() || !enableHistory) {
return;
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
deletePrevious(result.getText());
}
ContentValues values = new ContentValues();
values.put(DBHelper.TEXT_COL, result.getText());
values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());
SQLiteOpenHelper helper = new DBHelper(activity);
SQLiteDatabase db = null;
try {
db = helper.getWritableDatabase();
// Insert the new entry into the DB.
db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
} finally {
close(null, db);
}
}
示例15: addHistoryItem
import com.google.zxing.client.android.Intents; //导入依赖的package包/类
public void addHistoryItem(Result result, ResultHandler handler) {
// Do not save this item to the history if the preference is turned off, or the contents are
// considered secure.
if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
handler.areContentsSecure()) {
return;
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
deletePrevious(result.getText());
}
ContentValues values = new ContentValues();
values.put(DBHelper.TEXT_COL, result.getText());
values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());
SQLiteOpenHelper helper = new DBHelper(activity);
SQLiteDatabase db = null;
try {
db = helper.getWritableDatabase();
// Insert the new entry into the DB.
db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
} finally {
close(null, db);
}
}