I have a text box that takes the users input then launches this link or launches a reddit app (depending on what the user chooses in the chooser that appears). For some reason when you click the textbox to start typing, the chooser comes up without leaving the user a chance to even start typing. Why is this happening and how can I make it so that the chooser only comes up after the user submits their text?
public void searchBar(View view)
{
EditText et = (EditText)findViewById(R.id.editTextSearchBar);
String input = et.getText().toString();
String goTo = "http://reddit.com/r/"+input;
Uri webpage = Uri.parse(goTo);
Intent webIntent = new Intent(Intent.ACTION_VIEW,webpage);
startActivity(webIntent);
}
<EditText
android:id="@+id/editTextSearchBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/redditHint"
android:inputType="textUri"
android:imeOptions="actionGo"
android:onClick="searchBar"
/>
I understand that this code does not account for the instance of the user not entering any text but hitting enter anyway. For all intensive purposes, lets assume the user does enter some text.