QRコードをスキャンするのにhttps://github.com/dm77/barcodescannerを使用しています。 しかしQRコードはまったくスキャンされません(handleResultは決して呼び出されません)。カメラをQRコードにフォーカスすると、コードをスキャンしません。Android:ZXingScannerView by-me.dm7.barcodescanner:zxing:1.9 ScanQRコードがありません
ここは私の活動です。
package education.qrexample;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.google.zxing.Result;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
public class MainActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler{
private ZXingScannerView mScannerView;
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
mScannerView = new ZXingScannerView(this); // Programmatically initialize the scanner view
setContentView(mScannerView);
mScannerView.setResultHandler(this); // Register ourselves as a handler for scan results.
mScannerView.startCamera(); // Start camera on resume// Set the scanner view as the content view
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
mScannerView.stopCamera(); // Stop camera on pause
}
@Override
public void handleResult(Result rawResult) {
Toast.makeText(this,rawResult.getText(),Toast.LENGTH_LONG);
}
}
私のGradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "education.qrexample"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'me.dm7.barcodescanner:zbar:1.9'
compile 'me.dm7.barcodescanner:zxing:1.9'
}
私はすでにmainfestsファイル内のカメラにアクセスする権限を持っています。不明なものは何ですか?
あなたのマニフェストに 権限を追加しましたか? –
私はすでにコードにアクセス許可が追加されています。とにかく私はgr8を働いているスイッチビジョンAPIを持っています。 – Sandy