こんにちは、私のアプリにZxingスキャナーを統合しましたが、問題はバーコードをスキャンしたくないですが、 Zxingアプリを単独で開くと、バーコードスキャナが機能します。それは私が構築しているアプリから起動するときだけ動作しません。誰もが以前にこの問題を抱えていて解決策を見つけましたか?Zxingバーコードスキャナーは、アンドロイドアプリと統合されたときにバーコードをスキャンしていません
static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";
//product barcode mode
public void scanBar(View v) {
try {
Intent intent = new Intent(ACTION_SCAN);
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
} catch (ActivityNotFoundException anfe) {
//on catch, show the download dialog
showDialog(BarcodeScanner.this, "No Scanner Found", "Download a scanner code activity?", "Yes", "No").show();
}
}
// start qr stuff //product qr code mode
public void scanQR(View v) {
try {
//start the scanning activity from the com.google.zxing.client.android.SCAN intent
Intent intent = new Intent(ACTION_SCAN);
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
} catch (ActivityNotFoundException anfe) {
//on catch, show the download dialog
showDialog(BarcodeScanner.this, "No Scanner Found", "Download a scanner code activity?", "Yes", "No").show();
}
}
//alert dialog for downloadDialog
private static AlertDialog showDialog(final Activity act, CharSequence title, CharSequence message, CharSequence buttonYes, CharSequence buttonNo) {
AlertDialog.Builder downloadDialog = new AlertDialog.Builder(act);
downloadDialog.setTitle(title);
downloadDialog.setMessage(message);
downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
Uri uri = Uri.parse("market://search?q=pname:" + "com.google.zxing.client.android");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
act.startActivity(intent);
} catch (ActivityNotFoundException anfe) {
}
}
});
downloadDialog.setNegativeButton(buttonNo, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
}
});
return downloadDialog.show();
}
//on ActivityResult method
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
//get the extras that are returned from the intent
String tagNo = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
MySOAPCallActivity cs = new MySOAPCallActivity();
//tagNo = editTagNumber.getText().toString();
final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
// Get name and email from global/application context
String eventName = globalVariable.getEventName();
if(Local.isSet(getApplicationContext(), "EventName"))
{
eventName = Local.Get(getApplicationContext(), "EventName");
}
if(eventName.length() > 0) {
TagParams params = new TagParams(cs, tagNo, eventName);
//Make yes no buttons visible
Button buttonYes = (Button)findViewById(R.id.buttonYes);
Button buttonNo = (Button)findViewById(R.id.buttonNo);
buttonYes.setVisibility(View.VISIBLE);
buttonNo.setVisibility(View.VISIBLE);
TextView nameSurname = (TextView) findViewById(R.id.nameSurname);
nameSurname.setText("");
TextView idNumber = (TextView) findViewById(R.id.idNumber);
idNumber.setText("");
TextView ticketClass = (TextView) findViewById(R.id.ticketClass);
ticketClass.setText("");
new CallSoapTicketValidForEvent().execute(params);
}
}
;
}
}
そして、ここでのGradle
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.dsouchon.TicketingMiiD"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/ksoap2-android-assembly-3.4.0-jar-with- dependencies.jar')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.0.0'
compile files('libs/CircleImageView-master/gradle/wrapper/gradle- wrapper.jar')
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.jakewharton:process-phoenix:1.1.1'
}
デバッグあなたは何を見つけたのですか? –
あなたのコードとbuild.gradleを共有しますか? –
@AbhijitChakra私はデバッグで何かを見つけました。 –