Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in Switch cases of ZXing project in android

Tags:

android

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

like image 462
Khushi Avatar asked Jun 27 '12 13:06

Khushi


1 Answers

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.

like image 157
arne Avatar answered Nov 15 '22 04:11

arne