5

I have downloaded the ZXing project from the http://code.google.com/p/zxing/downloads/detail?name=ZXing-2.0.zip&can=2&q= and followed all the steps of http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/.

But my ZXing project is giving error in switch cases of ZXing Library.

Error is in following code

private final Handler handler = new Handler() {
    @Override
    public void handleMessage(Message message) {
      switch (message.what) {
        case R.id.search_book_contents_succeeded:
          handleSearchResults((JSONObject) message.obj);
          resetForNewQuery();
          break;
        case R.id.search_book_contents_failed:
          resetForNewQuery();
          headerView.setText(R.string.msg_sbc_failed);
          break;
      }
    }
  };

error is in switch statement error is "case expressions must be constant expressions"

Any Idea ? Thanxs

Khushi
  • 91
  • 2
  • 11

2 Answers2

13

You need to convert the case statements to if statements if you compile zxing as a library. Select the text in eclipse and use ctrl+1 to let eclipse do this for you.

arne
  • 224
  • 3
  • 2
5

Click on the switch keyword and press Ctrl + 1 on Windows/Linux and Cmd + 1 on Mac, select "convert switch to if else".

Goran Horia Mihail
  • 3,536
  • 2
  • 29
  • 40