-1

当我运行模拟器时,我在我的代码代码中使用条形码库工作正常,此错误将出现原因:android.content.ActivityNotFoundException:未找到处理 Intent { act=com.google.zxing.client.android.SCAN }

                      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" />

4

1 回答 1

0

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

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

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

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

另请注意,ZXing 团队没有官方“图书馆”,我上次检查过。

于 2013-06-11T16:27:34.570 回答