2017-02-15 146 views
0

カメラがポートレートモード,カスタムカメラの表示サイズにあるZXingスキャナーのAndroidでカスタムビューを作成したいと思います。私は同じビューでフラグメントを介してヘッダーとフッターを持っていますが、カスタムレイアウトでZXingを作成することはできません。私はフルスクリーンで作った。ZXingカスタムレイアウトのQRコードスキャナー

申し訳ありませんが、私はスプーン摂食のビットを必要とするかもしれません。

compile 'com.journeyapps:zxing-android-embedded:[email protected]' 
    compile 'com.google.zxing:core:3.2.0' 

上記ライブラリ私が使用されるが、それはコードの下に使用してフルスクリーンになります:

スキャンアクティビティ:

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 

import com.google.zxing.integration.android.IntentIntegrator; 
import com.google.zxing.integration.android.IntentResult; 

import prizeops.com.merchant.service.CallActivityService; 
import prizeops.com.merchant.service.HelperUtil; 
import prizeops.com.merchant.service.PrizeService; 

public class ScanActivity extends Activity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     IntentIntegrator integrator = new IntentIntegrator(this); 
     integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES); 
     integrator.setPrompt("Scan QRCode"); 
     integrator.setCameraId(0); 
     integrator.setOrientationLocked(true); 
     integrator.setBeepEnabled(true); 
     integrator.setCaptureActivity(CaptureCodePortraitActivity.class); 
     integrator.initiateScan(); 
    } 
    @Override 
    protected void onActivityResult(int req, int res, Intent intent) { 
     IntentResult intentResult = IntentIntegrator.parseActivityResult(req, res, intent); 
     if(intentResult != null){ 
      if(intentResult.getContents()==null){ 
       HelperUtil.makeToast(this, "Scanning been Cancelled."); 
       CallActivityService.gotoHomeActivity(this); 
      } 
      else 
       PrizeService.verifyPromoCode(this,intentResult.getContents(),false); 
     } 
     else { 
      super.onActivityResult(req, res, intent); 
     } 
    } 
} 

CaptureCodePortraitActivity:

import com.journeyapps.barcodescanner.CaptureActivity; 

public final class CaptureCodePortraitActivity extends CaptureActivity {} 

私はいくつかGithubの記事を見ましたが、私はそれをカスタマイズする方法を理解できませんでした:

https://github.com/journeyapps/zxing-android-embedded

https://github.com/journeyapps/zxing-android-embedded/blob/master/sample/src/main/java/example/zxing/ContinuousCaptureActivity.java

が、マニフェストでポートレートモードでカメラを開くには、ヘルプ

答えて

1

、としてCaptureActivityを追加します。これは、画面の向きを置き換えます

android:name="com.journeyapps.barcodescanner.CaptureActivity" 
    android:screenOrientation="portrait" 
    tools:replace="screenOrientation" /> 

=風景これはZxingライブラリのデフォルトとして使用されます。

+0

私はsame.butを試みましたが、未解決のパッケージjourneyappsエラーがマニフェストファイルに入っています。私は前述の4つの依存関係を使用しています。 CaptureActivityクラスパッケージは、マニフェスト宣言では受け入れられません。 – harikrishnan

+0

gradleに依存関係を追加しましたか?アプリケーションのグラデーションでex:compile 'com.journeyapps:zxing-android-embedded:3.4.0'の依存関係を追加してください。 – shell22

関連する問題