2

I want to search a string on Google and have the results shown in another page of my activity.

My code for searching right now is:

    Button breakfast = (Button) findViewById(R.id.breakfast);
        breakfast.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
//                Intent myIntent = new Intent(view.getContext(), Main5Activity.class);
//                startActivityForResult(myIntent, 0);

                try {
                    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
                    String term = Main2Activity.choice + " breakfast recipe using " + Main3Activity.list;
                    intent.putExtra(SearchManager.QUERY, term);
                    startActivity(intent);
                } catch (Exception e) {
                    // TODO: handle exception
                }

            }
        });

However, right now it is set up so that when the code runs it uses an outside google app to search and then uses that app to display results. I want to search still inside of my app and display the results in the next activity(Main5Activity). As you can see, the Main5Activity is already set up but I commented it out because I am not sure how to implement this.

This is the scrollview I want the results to be displayed in:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</ScrollView>

I am new to Google API, so using an outside app to google search was all I could do. Any help is greatly appreciated.

Larry Jing
  • 383
  • 1
  • 5
  • 26
  • Have you seen: [What are the alternatives now that the Google web search API has been deprecated?](https://stackoverflow.com/q/4082966/295004) – Morrison Chang Apr 23 '18 at 02:12
  • Morrison Chang I looked that up and all, but its more for websites I think. Not really what I'm looking for – Larry Jing May 21 '18 at 04:59

0 Answers0