So I am building an floating application that would allow user to browse webpages and allow them to listen audio from video sites like YouTube, etc. even when the device is locked/in background. Here I have a text box where user can input the websites or any text that they want to search i.e. SomeSite.com, www.SomeSite.com, Some Text To Be Search
I want to know is there any efficient way to do this. Currently I am thinking differentiating this by counting space in text (if there is 1 or more space then text is definitely not URL). But this won’t work for 1 word search query. Also another way is to check for top level domain like .com, .in, .uk, etc. not good as there could be thousands of domains and in future also it could increase.
I just want a effective to differentiate site or an web address
You can use the Patterns class available from API level 8.
if (Patterns.WEB_URL.matcher(myUrl).matches()) {
// Go to website
} else {
// Submit as search query
}
You can use
isValidRul()
Patterns.WEB_URL.matcher
Check if Uri.parse() returns valid value
Related
I'd like to allow users to type in an address in my Android app. The Google app provides a nice street address input field to allow the user to enter their home & word addresses. As a street address is being typed, incremental suggestions appear below the text input - an example is shown in the image below. How can I do something similar in my app? Is there a widget that does this?
Well only if you have a way of searching as the user types in the address. Like onTextChange event of the edit text! you can push query to some server say google maps that provides for the auto-completion on partial query strings.. or if you have a local datastore of previous searches you can provide auto completion on that as well but it'll be very limited.
I ended up using this example code:
https://github.com/googlesamples/android-play-places/tree/master/PlaceComplete
Hope it helps somebody else!
I am trying to write a little Android app for my daughter. The goal is to scan a book's bar code and pass the ISBN number to this website: http://www.arbookfind.com/default.aspx . The result will show if the book is part of the Accelerated Reader program and how many points the book is worth. I am trying to automate the part where the ISBN would need to be entered into the search field.
For simplicity's sake, and because I'm not a programmer, I am using MIT's App Inventor 2. I can now scan and get the ISBN but I will need to know how to format a URL to the website that will allow me to pass the ISBN to it's search page.
Is it possible to send a variable via the URL similar to index.php?myvar=testing&someothervar=somethingelse ? I've tried but perhaps I am not using the correct variable name or format for aspx. Is there an easy way to see what the variable name is in the aspx displayed page in my browser?
EDIT To clarify, I am not trying to scrape data and avoid showing ads from the site I am using to generate the results. I am wanting to pass the ISBN number to the page and have it search and display the resulting page in the phone's browser. I am also fine with a method that would populate the search field and the user would have to hit the search button if that can be accomplished easier.
I would recommend abandoning this route, as it is highly unlikely that the owners of this website will want you passing a query string to their site anyway, but rather they will most likely point you to an Application Programming Interface (API) that they provide, so that your program can connect to this service (free or paid, depending upon the company) and then you can request the book's details by providing the ISBN in the request.
There is no discovery mechanism for an .aspx page like there is for a web service to find out the names of things to pass. Even if you figure out what the name of the query string is that you could pass in for ISBN, you run the risk of the implementation being changed and your "application breaking". While this is also true of web service APIs, since APIs are the route the website providers want you to use, as opposed to screenscraping, then they generally inform their users of breaking changes or newer versions of the API via documentation.
From what I can see that page does not accept URL-variables for their search field the way google.com and other does. The page is generated through some sort of content management system (CMS) and it relies heavily on javascript to make things work. I tried doing a normal search there, and you have two issues you need to wriggle around.
First, the page redirects you to a page where you select if your a student, parent etc. It seems that it relies on some session cookie to remember the setting, but it times out pretty fast.
Second, the form uses javascript to trigger the search, and it appears to be done using AJAX, a method of using javascript to trigger actions on the server and displaying the results, without actually loading the page again. You might be able to get a hold of the javascript code used and re-engineer it for your purposes, and call that using HTTP POST and/or GET from your app, but it is a tricky path, and quite possibly not allowed by the company since you will be loading data from their site, without presenting their advertisements and thus be costing them money.
I'm trying to search a website for information (i.e. lets say I make an application for cinemas, the user inputs the name of the film and the cinema he wants and the application prints the times).
So in the background the application would go to the cinemas webpage, use the webpages search engine, parse the page and print a list of times.
I honestly don't know where to start so any help or tips would be most welcome.
Thank you in advance,
Aterin
After much thought I found a way of doing this, I need to use a GET with the url and fill in the url based on the input of the user.
For example on the website http://www.overclockers.co.uk/ it would be:
String url = "http://www.overclockers.co.uk/search_results.php?keywords=" + keyword + "&cat=" + cat;
and then filter the resulting HTML based on the websites CSS (in this case they have a tag for listing products, so all I need to do is search for the alt = keyword and then do another GET with the corresponding href.
There is however a serious problem with this method, if the website is altered then all this goes down the sink hole. That said, I can't think of any other solution.
You would need to first locate a suitable API to serve your data and then parse the data within your application to display it as you deem fit.
Some info on Movies API
I was wondering if it was at all possible to attempt the following in an Android app:
I want the user to be able to enter a few keywords, then in the background (while showing a loading animation) have the app search google for the entered keywords, navigate to the first search result, then search the resulting web page for a URL leading to a particular domain, and return this URL to a list in the app?
Is this possible, and could anyone nudge me in the right direction to get this done?
You can use Google search api by Http request methods in backend while showing loading animation, which provides its search results details...
But also look out for restrictions in using this api, i guess in terms of max search requests/day..
So I'm building an app that allows input from the user with their voice. I have built a webview and i have all the code to recieve voice input and transcode that into text. But now i want to be able to paste the text that the user says that i have already into whatever text box that is selected on the screen. For instance if the user is on google and clicked on the search box and says the words "stackoverflow", my app recieves the string containing "stackoverflow", now how do i paste that into the text box?
Thanks and let me know if i can give any further clarification
Unless you knew exactly what page the user had opened and exactly what the ID of the element you wanted to populate was, there's no way to accomplish what you're describing (if I understand your request correctly). Or are you asking how to populate an EditText that's in your Activity (I'm assuming that's NOT what you're asking, but just in case).