how to start a browser with yahoo search query in android - android

I was wondering if there is a way to start a Browser with a yahoo search query. For example user can select a certain word or phrase and click a button and the activity will start the browser with the yahoo search query.

The quickest way is with intents, like so:
String query = "my search terms";
String url = "http://search.yahoo.com/search?p=" + query;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Android will automatically attempt to open this in the application associated with URLs which, by default, should be their default web browser.

Try appending the search keyword to Yahoo search api url and accessing it via uri onClick new button in your activity.

Related

Get Google search results and show in android app

I want to display google search results in my android app,When the user type word in editText and click search button to get google search results and shown in inside my app.I have no experience to do this. please help me anyone
private static final String GOOGLE_SERACH_URL = "https://www.google.com/search?q=";
Then simply append the key you want to search on google after the URL and load your query string in a WebView.
webView = (WebView) rootView.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(GOOGLE_SERACH_URL + searchKey);
Working example
https://github.com/hiteshsahu/Android-Universal-Web-Content-Loader
You can use Intent class with the action web search.
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String keyword= "your query here";
intent.putExtra(SearchManager.QUERY, keyword);
startActivity(intent);
For better learning you can follow example program.

A general Android intent for a dictionary / encyclopedia / etc

Does there exist such a thing, where you send it a string as data, and it knows to open the application with the entry for that string?
Thanks.
if you want to allow user to search something new. Than you can not depend on other applications. This will launch the browser(which is present in all the android devices) with your text as the url so that user can search it using your app.
try this:
String url = "the text you want to search";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Or
the dictionary must have Broadcast Reciever

How do I launch a URL in browser from an OnClick event on a TextView?

I have read the answer "How do I launch a URL in the browser from my Application on Android" but I am still confused.
------>
Basically I have a TextView that will be displaying different names of famous people, and what I want is, to perform a google search in the browser that searches for the text that is currently displayed in the TextView, when the user clicks on the TextView itself.
Thanks.
in onClickListner event write this code:
String url = textView.getText().toString();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Well, what I understand is that you want to launch Google search for the text when you click on the TextView. Here is a code to directly launch Google search of the text provided:
String searchKey = "Text From your TextView";
Intent search = new Intent(Intent.ACTION_WEB_SEARCH);
search.putExtra(SearchManager.QUERY, searchKey);
startActivity(search);

Getting the url when opening the application particular Activity by clicking the SMS url

I am able to open the sub Activity through the intent filter by clicking in the SMS url, but I need to access the URL so, that the ID which come from other activity can be access through the url directly to that sub Activity. so, how it can be done... for further information please kindly ask any queries. Thank you for your concern.
If it was a web url that was intercepted, for example "www.roflcopter.se/hai/2u", then the data can be extracted like this:
Intent intent = parent.getIntent();
String action = intent.getAction(); // for example Intent.ACTION_VIEW
String host = intent.getData().getHost(); // "www.roflcopter.se"
List<String> segments = intent.getData().getPathSegments(); // {"hai", "2u"}
The same syntax can be used for all types of intercept. See which of these methods that return the data you are interested in. :)

Android - Call default browser with and redirect to a designated url

Hi
I want to write an app to call default browser and redirect to a designated url.
Any suggestion to 1)call the default browser, 2)redirect to a designated url.
Thanks
you just want to launch an ACTION_VIEW intent with the Uri of the webpage as your data element :
Intent httpIntent = new Intent(Intent.ACTION_VIEW);
httpIntent.setData(Uri.parse("http://www.bbc.co.uk"));
startActivity(httpIntent);
To open the default browser use an Intent with the action VIEW. To tell the browser which page to load us the data-part of the Intent.
Example:
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse("http://stackoverflow.com"));
startActivity(browse);
Since this is a basic task in Android you might want to read some basics about Intents in Android.

Categories

Resources