0

So I'm new to Android Development. and I'm writing a Browser app for practice. The goal is for a user to be able to enter a URL and a website pulls up or just keywords for a google search in the search/browser bar. The problem im having is, its just preforming google searches but does not recognize if a URL was entered. I have no errors. debugging makes me feel as if the app is fine and working and there are no errors that's stopping the app. Im at a loss in my head for what the problem could be. below is the code

button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);


                if (editText.getText().toString() == "whateverText") {
                    // this line is looking for a keyword or URL
                }

                webView.loadUrl("https://" + editText.getText().toString());
                webView.loadUrl("https://www.google.com/#q=" + editText.getText());
                /* these 2 lines are needed to identify if its a URL search or Keyword search */


            }


        });

I've coded with Booleans before in the past, I'm just lost to where and how I implement this within a browser. from my understanding a Boolean cannot be set up with a public void and the android studio reference site is not giving me much info. please help if you can. it would be greatly appreciated. thanks in advance

J One
  • 33
  • 7
  • Not sure what you mean by “ a Boolean cannot be set up with a public void”. Also your code has the classic mistake of comparing Strings with “==“ rather than “.equals()”, which wouldn’t be helping. – racraman Jan 23 '20 at 21:11
  • 1
    Does this answer your question? [How to verify if a String in Java is a valid URL](https://stackoverflow.com/questions/3931696/how-to-verify-if-a-string-in-java-is-a-valid-url) – greeble31 Jan 23 '20 at 21:49

0 Answers0