2013-06-11 39 views
-1

即時通訊使用我的代碼中的條形碼庫工作正常當我運行模擬器這個錯誤將來到由於:android.content.ActivityNotFoundException:沒有找到活動發現處理意圖{動作= 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" /> 

使用條碼庫在我的代碼

+0

http://stackoverflow.com/questions/12220140/no-activity-found-to-handle-intentact-com-google-zxing-client-android-scan-cat – L7ColWinters

+0

https://code.google.com/p /斑馬線/維基/ ScanningViaIntent – Voicu

回答

0

IM

你可能會認爲你是。沒有這方面的證據。

當我運行模擬器這個錯誤會

那是因爲你沒有支持com.google.zxing.client.android.SCANIntent動作安裝在你的模擬器的應用程序。 ZXing Barcode Scanner應用程序支持此操作,您可以將download應用程序安裝到您的仿真器上(儘管我沒有在仿真器上嘗試它,所以我不知道它會如何工作)。

另外請注意,ZXing團隊沒有官方的「圖書館」,最後我檢查了一下。