qrコードリーダーアプリケーションを作成していて、zXingリソースを利用しました。電話機でアプリケーションを実行した後、「Found URL」と表示され、特定のqrコードのリンク。それは私の主な活動に戻ってきます。 私のプロジェクト名は「スキャン」で、core.jarファイルを追加しました。私も「スキャンQRコード」という名前のボタンと1つのレイアウト・ページ、すなわちmain.xmlを持ち、活動名は「ScanActvity.javaは、」私のプロジェクトの全コードはようです:QRコードリーダーが特定のリンクにリダイレクトされない
ScanActivity.java
package com.scan.qr;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class ScanActivity extends Activity {
/** Called when the activity is first created. */
Button btnScan;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnScan = (Button) findViewById(R.id.button1);
btnScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/button1"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Scan qr code" />
</RelativeLayout>
</LinearLayout>
ActivityMainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.scan.qr"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ScanActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
また、 "scan"という名前のプロジェクトにcore.jarファイルを含む "zcore"というフォルダを追加し、プロパティに "JavaBuildPath"の下に "core.jar"という名前のjarファイルを追加しました私のプロジェクトの "zcore"フォルダ。
が、今私はエミュレータでこれを実行しようとしたことは私にこのようなエラーメッセージが表示できます:
AndroidRuntime(401): at
com.google.zxing.client.android.camera.CameraManager.getFramingRectInPreview
(CameraManager.java:218)
AndroidRuntime(401): at
com.google.zxing.client.android.ViewfinderView.onDraw(ViewfinderView.java:117)
AndroidRuntime(401): at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830)
dalvikvm(401): Unable to open stack trace file '/data/anr/traces.txt': Permission
denied
をして、私は三星銀河Yの携帯電話上のAPKファイルを実行しようとした私がクリックしたときに、それが正常に動作し、 「qrコードをスキャンする」ボタンを押すとカメラが開き、カメラの前にqrコードの画像を置くとqrコードが検出されて「Found URL」と表示され、メインページが再び開き、リダイレクトされません私は特定のURLに私。どのように私がリダイレクトされ、私にQtコードの情報を表示するのかわかりますか?なぜ私はURLにリダイレクトされないのですか?qrコードをスキャンした後にメインページを再び開くのはなぜですか?
この問題の解決方法を教えてください。私がやったことが間違っているのか、それともqrコードリーダーを作る際に何かするべきことがあるのですが、qrコードリーダーにフィルタを追加する方法を教えてください。
を参照してください。私はURLを起動するコードはありませんが、Web上のすべてのQrコードのURLを入力する方法を理解していれば、私はqrコードの情報、またはそのURLを私がそのウェブサイトにリダイレクトする必要がある場合、このアイデアは、手動でコードに入力する特定のURLのために働くもので、情報を自動的に取得し、そのように機能させることができます。 – user1161410