0

Helli, I got an error message ") expected" with my code

this is my code

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data){
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode==RESULT_OK){
            if (requestCode == 1){
                File f = new File(Environment.getExternalStorageDirectory().toString()
                for (File temp : f.listFiles()){
                    if (temp.getName().equals("temp.png")){
                        f = temp;
                        break;
                    }
                }
Sylhare
  • 5,907
  • 8
  • 64
  • 80
  • It seems you forgot a couple of `}` in that piece of code. Do you have the line of the stacktrace, try following to see which line is the problem. – Sylhare Feb 24 '20 at 18:51
  • @Sylhare Since this is a compile-time error, there is no stacktrace. But the full error message should be posted. – kaya3 Feb 24 '20 at 20:02
  • As well as the other comments/notes, `.toString()` needs to be `.toString());`. That will prevent the specific syntax error mentioned in the question. I hope you are using an IDE, such as Eclipse. – andrewJames Feb 24 '20 at 21:00

1 Answers1

0

2 compile issues in your code, this is a correction

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode==RESULT_OK) {
        if (requestCode == 1) {
            File f = new File(Environment.getExternalStorageDirectory().toString());
            for (File temp : f.listFiles()) {
                if (temp.getName().equals("temp.png")){
                    f = temp;
                    break;
                }
            }
        }
    }
}

Issue 1: following line was missing );

File f = new File(Environment.getExternalStorageDirectory().toString()

Issue 2: at the end you missed 3 curly brackets }

ksclfanatic
  • 122
  • 1
  • 10