How to get a specific text from a web page Android Studio?
First of all, you need to find "HOW THAT WEBPAGE IS GETTING THAT DATA?",
1-If it is hard coded you can hardcode it in your android application.
2-If it is coming from any web service you need to parse JSON data into you application.
That's how you get the specific data from any web page.
Related
We have a phone gap cross-platform built app and we are building the same app in native.
The app has pages/views with text with embedded hyperlinks in them where it sends the user to other pages in the same app. Of course because this is HTML based so this is possible using phone gap apps. But what if we changed that to native how can we have links inside a text where it redirects users to other views or grabs other data from the database and pushes them to the UIViewController?
How will the backend send us JSON strings with hyperlinks in them that will be able to replicate what the phone gap built app does. Is this possible?
Ok maybe we can send embedded HTML in the JSON data. But how will these <a> links open or grab other data from the server?
I find it very complicated or maybe not doable at all. Anybody has ideas on how this could be solved?
A screen shot of what i mean. This is a phone gap app.
All right first and foremost you need structured data.
Lets say I opend a main post with id '14'. Api will fetch data from server for id 14.
JSON structure can be like this:
{"title":"What are origional sin?","content":"Although Adam & Eve had been given. God has given man free will.","inlineLinks":[{"startIndex":"8","endIndex":"18","contentId":"141"},{"startIndex":"55","endIndex":"64","contentId":"142"}]}
Now using spannable string in android and attributed string in ios you now have id for specific inline link content and start and end index which you can use to add clicks to specific inline links. Once user clicks these link you have id of that specific content which you can open in your app.
Since you know the spannable string I hope you dont need the detail code.
Wish you have started your question with Spannable String problem.
Please ignore the indexes incase they are wrong ;)
From an Activity, How can I retrieve code or text from a website and display to the user ? I'm having difficulties programming back to Android, now developing as for Android 6.0 and newer. Getting deprecated about http client etc.. so I need a little of help.
Can you paste me some code example including "imports" in order to when the app load, from an Activity class, and also when a user click a "button1", to retrieve the text displayed from a web say "yahoo.es", and show a message to the user with the text from the web (loaded and parsed to a string) using Toast.
Help much appreciated in advance
Firstly you are way too ambiguous about your question. Correct me if i am wrong, what you basically want is to get data from internet and display them to user. Right.
If Yes, then the best way to do this is to get JSON response and parse it to display the relevant information onto the screen.
Take for example, you want an App displaying current Weather status of a city.Then to get the Weather data from Internet you need to connect to those websites which provide you that data.
Now one such website is OpenWeatherMap.org. You can use its APIs to retrieve data in JSON format and then display. You need to go through its API documentation.
This is link which will explain you the full process of connecting to an website's API, its retrieval of Data in Json format and ways to render and display them on screen effectively.
https://www.udacity.com/course/android-basics-networking--ud843
Hope it helps.
Let's say there's website X. Website X has a search function that'll return articles/documents/whatever. Whatever it returns will include a link so the user could click on it to go to said article. All of this would be without an API. Would it be possible for an android application to query a search on a random website, get the results and display them in the app, without the user actually seeing the website?
Yes, of course. All you want to do is write the app such that it performs the query to the website on behalf of the user; that way it gets the HTML response. When it gets the HTML page as a response, you parse that and reformat it into something more appropriate for the app.
Look at this SO question if you want more information on HTML parsers in Java: Parse HTML in Android
Hey basicaly im developing an application for the rugby team i play for and need a way to display match results is there a way to update these easily within an application? or is it best to just use web view and link it to a html page i'd rather they didnt have to load a web page each time if at all possible but at the same time thats better than doing a full app update each week.
Thanks in advance
Ashley Waters
Use xml parsing, in your app and check on each launch of your app if your live xml is updated, otherwise save the data and keep showing that data on your app.
For that you have to create a web-service which throws/get request/response either in XML or JSON. While getting response you have to parse XML or JSON and display it inside the application.
If you want to update the application by making web call automatically then implement Background call and set timer for service so that it continuously check whether any data is updated at web or not.
I want to develop an android application that will access web pages.Like my browser will first load "www.mail.yahoo.com".then it automatically set yahoo id and password that i will tell from my program.then it will automatically click in sign in to sign in.Like web browser control in visual basic 6 or in c# application.In android i can browse pages using web view but not getting any way to access html content as i have been trying for a week.If any body will help it will be great pleasure.
Thanks
You can use WebView for accessing URLs and let the users see the content.
A poorman's solution to get the HTML is to open the URL with another HttpConnection in another thread and read the contents of it. just because I haven't find any other way to access the HTML that is loaded in the WebView