编译时条码显示错误请帮帮我

时间:2013-06-11 16:21:32

标签: android

我在我的代码中使用条形码代码工作正常,当我运行模拟器时会出现此错误引起:android.content.ActivityNotFoundException:找不到处理Intent的活动{act = com.google.zxing.client.android。扫描}

                      package my.finalyear.demo;



    public class CaptureActivity extends Activity {

final Context context = this;
String contents;
String searchFor;
static final String KEY_ITEM = "item"; // parent node
static final String KEY_ID = "id";
static final String KEY_NAME = "name";
static final String KEY_COST = "cost";
static final String KEY_DESC = "description";

public static String name, cost, description;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    startActivityForResult(intent, 0);

}

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {

            // String result =intent.getAction();
            contents = intent.getStringExtra("SCAN_RESULT");
            String format = 
      intent.getStringExtra("SCAN_RESULT_FORMAT");






                  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.finalyear.demo"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    />

<application
    android:icon="@drawable/launcher_icon"
    android:label="@string/app_name"
    >
    <activity
        android:name=".LoginActivity"  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.LAUNCHER" />
        </intent-filter>
    </activity>





    <activity
        android:label="MainScreen"
        android:name=".CaptureActivity" >
    </activity>


    <activity
        android:label="Single Menu Item"
        android:name="my.finalyear.demo.SingleMenuItemActivity" >
    </activity>
</application>

<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

  <uses-feature android:name="android.hardware.camera.flash" />

  

1 个答案:

答案 0 :(得分:0)

  

我在我的代码中使用条形码

你可能认为你是。没有证据证明这一点。

  

当我运行模拟器时会出现此错误

这是因为您的模拟器上没有安装支持com.google.zxing.client.android.SCAN Intent操作的应用程序。 ZXing Barcode Scanner应用程序支持此操作,您可以download并在您的模拟器上安装(虽然我没有在模拟器上尝试过,所以我不知道它的效果如何)。

另请注意,ZXing团队没有正式的“图书馆”,最后我查了一下。