简体   繁体   中英

No activity found to handle intent{act=com.google.zxing.client.android.ENCODE (has extras) } in zxing library?

I am developing QR Code generator app. I was doing it for location but my app crashes. Below is the error log file and the code for which i am getting error. I followed This Link . Kindly help me out

Error-log

07-18 06:13:43.776: D/AndroidRuntime(1668): Shutting down VM
07-18 06:13:43.776: W/dalvikvm(1668): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
07-18 06:13:43.835: E/AndroidRuntime(1668): FATAL EXCEPTION: main
07-18 06:13:43.835: E/AndroidRuntime(1668): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.ENCODE (has extras) }
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.app.Activity.startActivityForResult(Activity.java:3390)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.app.Activity.startActivityForResult(Activity.java:3351)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.app.Activity.startActivity(Activity.java:3587)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.app.Activity.startActivity(Activity.java:3555)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at com.example.qrcodegenerator.LocationQRCode.onClick(LocationQRCode.java:61)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.view.View.performClick(View.java:4240)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.view.View$PerformClick.run(View.java:17721)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.os.Handler.handleCallback(Handler.java:730)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.os.Looper.loop(Looper.java:137)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at android.app.ActivityThread.main(ActivityThread.java:5103)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at java.lang.reflect.Method.invokeNative(Native Method)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at java.lang.reflect.Method.invoke(Method.java:525)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-18 06:13:43.835: E/AndroidRuntime(1668):     at dalvik.system.NativeStart.main(Native Method)

Code

case R.id.locQRBtn:

        EditText lat = (EditText) findViewById(R.id.etLat);
        EditText longi = (EditText) findViewById(R.id.etLong);

        String latitude = lat.getText().toString();
        float latit = Float.parseFloat(latitude);

        String longitude = longi.getText().toString();
        float longit = Float.parseFloat(longitude);

        Bundle data = new Bundle();
        data.putFloat("LAT", latit);
        data.putFloat("LONG", longit);

        Intent i = new Intent("com.google.zxing.client.android.ENCODE");
        i.putExtra("ENCODE_TYPE", Contents.Type.LOCATION);
        i.putExtra("ENCODE_DATA", data);
        startActivity(i);

        // Find Screen Size
        WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
        Display display = manager.getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);
        int width = point.x;
        int height = point.y;
        int smallerDimension = width < height ? width : height;
        smallerDimension = smallerDimension * 3 / 4;

        // Encode with a QR Code image
        QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(null, data,
                Contents.Type.LOCATION, BarcodeFormat.QR_CODE.toString(),
                smallerDimension);

        try {
            Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
            ImageView myImage = (ImageView) findViewById(R.id.locQRCode);
            myImage.setImageBitmap(bitmap);

        } catch (WriterException e) {
            e.printStackTrace();
        }
        break;

You do not have the Barcode Scanner app installed, but you are trying to call to it by Intent . That is exactly why you get ActivityNotFoundException . Install Barcode Scanner in your emulator. The latest .apk is at https://github.com/zxing/zxing/releases

You do not need to include other classes from the project. In fact you shouldn't. They are irrelevant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM