I have a requirement wherein if there is any URL in text messages i.e when we are chatting using android phone and someone send me a url , then i should display the content in the URL in a small window so that he does not have to click the URL to see the content but automatically sees the content of that webpage . Any idea on how this can be implemented because when i was looking to the messaging api , it is displaying it through cursor adapter so somehow this webview needs to be stored in db . Am i on the right track . Any suggestions ?
First you need to detect that you have a URL. You can do this using a Regex.
Then, you need to write an xml layout for your View which includes a WebView. You can find basic usage and examples here: http://developer.android.com/reference/android/webkit/WebView.html.
Whether you store the messages in a db or not is up to you, depending on your needs.
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.
Got a pretty hectic task for myself here and i'm done with googling it ..
Im presently working on an app that has to take an
input , (String )(EditText) from the user end .
Use that string and pass it on to a webview , so that the search is done based on this string , (for eg: lets take youtube as an example so the passed content is a Songs name).
Once the search has been made the app has to pickup the url of the present search made .... i.e in youtube when we search for something we get the url as
"https://www.youtube.com/watch?v=zS4F49XqLWo" so the app has to store this url .
Paste the url onto another site and then Click on some buttons on that site (The major problem part -- how do i get the app to automatically click on buttons on another site ??)
Im just a novice at Android Development , espacially at the html side of it ... so kindly bear with me !!...
I have developed an application in which there is one URL(JSON Link): https://zappos.amazon.com/mobileapi/v1/product/asin/B00LLS8LQU
I have shared this URL in whatsApp or any other application.
I have two Queries
My Query is: When the user clicks the URL.
My Application should be shown along with browsers.
Query 2:
After clicking on my application provided by action provider.
I need to get data from this JSON URL Link? How i can achieve that?
Below is the screenshot of problem:
If I understood you correctly, learn everything described here.
Documentation
I have developed some company website in that i had careers option.now using text view i am displaying job openings,but when they update in website app also should get update and if they want to post in app only means how i update or post job opening after placing in google play store. please explain with code.
WebView webView = (WebView)findViewById(R.id.wv);
webView.loadUrl("http://www.emergtechinc.com/Careers/careers-cjo.aspx");
I used webview and displayed the currenopenings page. Is it right but I got whole website page. How can I display whatever I need from website?
If you want to load specific data only, I would suggest an API on the backend of your website. Create a specific Activity in you app that queries the API, which would return data for job postings, and display it in any manner you would like.
If you want users to post to the site from the application, you will also need an API to handle the post.
#Prerak's answer will work as well and be less code than the method I am suggesting.