Note that there are some explanatory texts on larger screens.

plurals
  1. POBarcode scanning doesn't work if barcode reader app not installed
    text
    copied!<p>i am trying to make an application that will work on the phone to scan bar code. so i have tried the code bellow but it gives me this error</p> <pre><code>11-28 11:18:45.750: E/AndroidRuntime(772): FATAL EXCEPTION: main 11-28 11:18:45.750: E/AndroidRuntime(772): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.SCAN (has extras) } 11-28 11:18:45.750: E/AndroidRuntime(772): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622) </code></pre> <p>i am still trying this using emulator and external camera on my laptop. so can you please help me</p> <p>here is the code:</p> <pre><code>public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); HandleClick hc = new HandleClick(); findViewById(R.id.butQR).setOnClickListener(hc); findViewById(R.id.butProd).setOnClickListener(hc); findViewById(R.id.butOther).setOnClickListener(hc); } private class HandleClick implements OnClickListener{ public void onClick(View arg0) { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); switch(arg0.getId()){ case R.id.butQR: intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); break; case R.id.butProd: intent.putExtra("SCAN_MODE", "PRODUCT_MODE"); break; case R.id.butOther: intent.putExtra("SCAN_FORMATS", "CODE_39,CODE_93,CODE_128,DATA_MATRIX,ITF,CODABAR"); break; } startActivityForResult(intent, 0); //Barcode Scanner to scan for us } } public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { TextView tvStatus=(TextView)findViewById(R.id.tvStatus); TextView tvResult=(TextView)findViewById(R.id.tvResult); if (resultCode == RESULT_OK) { tvStatus.setText(intent.getStringExtra("SCAN_RESULT_FORMAT")); tvResult.setText(intent.getStringExtra("SCAN_RESULT")); } else if (resultCode == RESULT_CANCELED) { tvStatus.setText("Press a button to start a scan."); tvResult.setText("Scan cancelled."); } } } } </code></pre> <p>Here is Manifest</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="sdk.example.test" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="sdk.example.test.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload