0

我正在开发 QR 码生成器应用程序。我这样做是为了定位,但我的应用程序崩溃了。下面是错误日志文件和我收到错误的代码。我跟着这个链接。请帮帮我

错误日志

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)

代码

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;
4

1 回答 1

0

您没有安装 Barcode Scanner 应用程序,但您正试图通过 调用它Intent。这正是你得到ActivityNotFoundException. 在您的模拟器中安装条形码扫描仪。最新的 .apk 位于https://github.com/zxing/zxing/releases

您不需要包含项目中的其他类。事实上你不应该。它们无关紧要。

于 2014-07-18T11:14:54.023 回答