How can I get just the Video to play on Android? - android

I want to play just the video from youtube. but this code i use show more detail just like I open it from the website. how can I get ride of the detail like suggested video, comments, info.... I just want to have the Video on the app. Any help would be appreciate :) thanks
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
WebView webView1 =(WebView)findViewById(R.id.webView1);
webView1.getSettings().setAllowFileAccess(true);
webView1.getSettings().setLoadWithOverviewMode(false);
webView1.getSettings().setUseWideViewPort(false);
webView1.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView1.getSettings().setSupportMultipleWindows(false);
webView1.setWebChromeClient(new WebChromeClient());
webView1.setWebViewClient(new WebViewClient());
webView1.setWebViewClient(new Callback());
webView1.getSettings().setJavaScriptEnabled(true);
webView1.getSettings().setPluginState(PluginState.ON);
String video_path = "http://www.youtube.com/watch?v=jtrltr-uIvw";
Uri uri = Uri.parse(video_path);
uri = Uri.parse("vnd.youtube:" + uri.getQueryParameter("v"));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

Use VideoView instead of WebView.
VideoView video = (VideoView)findViewById(R.id.video);
video.setVideoURI(Uri.parse("insert rtsp here"));
video.start();

I had this problem some time ago. The trick is to determine the actual URL of the video and then use MediaPlayer to play the video.
Let's say, you're after this video: http://www.youtube.com/watch?v=ou87i6Oq5M0 - note the video tag: ou87i6Oq5M0. To get the URL of the actual video stream, you can retrieve this resource: http://gdata.youtube.com/feeds/api/videos/ou87i6Oq5M0?v=2 - this will return the metadata of the youtube video, including the actual URL of the stream:
<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag='W/"CkUCSH47eCp7I2A9Wh5WF00."'><id>tag:youtube.com,2008:video:ou87i6Oq5M0</id><published>2013-09-01T11:21:22.000Z</published><updated>2013-11-29T04:44:29.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='News' label='News & Politics'/><title>WORLDS FASTEST propellar driven AIRCRAFT Russian Tu 95MC Nuclear Bomber</title><content type='application/x-shockwave-flash' src='http://www.youtube.com/v/ou87i6Oq5M0?version=3&f=videos&app=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.in-response-to' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/hdFswfC_Egk?v=2'/><link rel='
alternate' type='text/html' href='http://www.youtube.com/watch?v=ou87i6Oq5M0&feature=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/ou87i6Oq5M0/related?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=ou87i6Oq5M0'/><link rel='http://gdata.youtube.com/schemas/2007#uploader' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/D8bmW4A7eYzHrW7sXwsqwQ?v=2'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/ou87i6Oq5M0?v=2'/><author><name>ArmedForcesUpdate</name><uri>http://gdata.youtube.com/feeds/api/users/ArmedForcesUpdate</uri><yt:userId>D8bmW4A7eYzHrW7sXwsqwQ</yt:userId></author><yt:accessControl action='comment' permission='allowed'/><yt:accessControl action='commentVote' permission='allowed'/><yt:accessControl action='videoRespond' permission='moderated'/><yt:
accessControl action='rate' permission='allowed'/><yt:accessControl action='embed' permission='allowed'/><yt:accessControl action='list' permission='allowed'/><yt:accessControl action='autoPlay' permission='allowed'/><yt:accessControl action='syndicate' permission='allowed'/><gd:comments><gd:feedLink rel='http://gdata.youtube.com/schemas/2007#comments' href='http://gdata.youtube.com/feeds/api/videos/ou87i6Oq5M0/comments?v=2' countHint='45'/></gd:comments><media:group><media:category label='News & Politics' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>News</media:category><media:content url='http://www.youtube.com/v/ou87i6Oq5M0?version=3&f=videos&app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='165' yt:format='5'/><media:content url='rtsp://r8---sn-5hn7su7l.c.youtube.com/CiILENy73wIaGQnN5KqjizvvohMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='165' yt:format='1'/
><media:content url='rtsp://r8---sn-5hn7su7l.c.youtube.com/CiILENy73wIaGQnN5KqjizvvohMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='165' yt:format='6'/><media:credit role='uploader' scheme='urn:youtube' yt:display='ArmedForcesUpdate' yt:type='partner'>armedforcesupdate</media:credit><media:description type='plain'>Russian Aircraft The Tupolev Tu-95 (Russian: Туполев Ту--95; NATO reporting name: Bear) is a large, four-engine turboprop-powered strategic bomber and missile platform. First flown in 1952, the Tu-95 entered service with the Soviet Union in 1956 and is expected to serve the Russian Air Force until at least 2040.[1] A naval development of the bomber is designated Tu-142.
The aircraft has four Kuznetsov NK-12 engines, developed by the Kuznetsov Design Bureau with participation of Ferdinand Brandner and other captured German engineers, each driving contra-rotating propellers. An airliner variant Tu-114 holds the record as the world's fastest propeller-driven aircraft. Some experimental aircraft were designed for theoretically higher speeds, but none attained or registered them. It also remains the only turboprop-powered strategic bomber in operational use. Its distinctively swept-back wings are at 35°, a very sharp angle by the standards of propeller-driven aircraft, and justified by its operating speeds and altitudes. Its blades, which rotate faster than the speed of sound, according to one media source, make it arguably the noisiest military aircraft on earth,[2] with only the experimental 1950s era Republic XF-84H "Thunderscreech" turboprop powered American fighter design as a likely rival.[citation needed] It was reportedly so loud that the underwater Hydrophones of
submerged submarines and SOSUS could detect it.
Russia Listeni/ˈrʌʃə/ or /ˈrʊʃə/ (Russian: Россия, tr. Rossiya, IPA: [rɐˈsʲijə] ( listen)), also officially known as the Russian Federation[10] (Russian: Российская Федерация, tr. Rossiyskaya Federatsiya, IPA: [rɐˈsʲijskəjə fʲɪdʲɪˈrat͡sɨjə] ( listen)), is a country in northern Eurasia.[11] It is a federal semi-presidential republic, comprising 83 federal subjects. From northwest to southeast, Russia shares land borders with Norway, Finland, Estonia, Latvia, Lithuania and Poland (both with Kaliningrad Oblast), Belarus, Ukraine, Georgia, Azerbaijan, Kazakhstan, China, Mongolia, and North Korea. It shares maritime borders with Japan by the Sea of Okhotsk and the US state of Alaska across the Bering Strait. At 17,075,400 square kilometres (6,592,800 sq mi), Russia is the largest country in the world, covering more than one-eighth of the Earth's inhabited land area. Russia is also the world's ninth most populous nation with 143 million people as of 2012.[12] Extending across the entirety of northern Asia and much
of Europe, Russia spans nine time zones and incorporates a wide range of environments and landforms.
An aircraft is a machine that is able to fly by gaining support from the air, or, in general, the atmosphere of a planet. It counters the force of gravity by using either static lift or by using the dynamic lift of an airfoil,[1] or in a few cases the downward thrust from jet engines.
The human activity that surrounds aircraft is called aviation. Crewed aircraft are flown by an onboard pilot, but unmanned aerial vehicles may be remotely controlled or self-controlled by onboard computers. Aircraft may be classified by different criteria, such as lift type, propulsion, usage and others.
The Russian Air Force (Russian: Военно-воздушные cилы России, tr. Voyenno-Vozdushnye Sily Rossii) is the aerial warfare service branch of the Armed Forces of the Russian Federation. It is currently under the command of Lieutenant General Viktor Bondarev. The Russian Navy has its own air arm, the Russian Naval Aviation, which is the former Soviet Aviatsiya Voyenno Morskogo Flota ("Naval Aviation"), or AV-MF).
The Air Force was formed from parts of the former Soviet Air Forces after the dissolution of the Soviet Union in 1991--92. Boris Yeltsin's creation of the Ministry of Defence of the Russian Federation on 7 May 1992, can be taken as a convenient formation date for the new Air Force. Since that time, the Air Force has suffered severe setbacks due to lack of resources, and has constantly shrunk in size. Since Vladimir Putin became President of the Russian Federation however, much more money has been allocated to the Armed Forces as a whole.
The United States Air Force (USAF) is the aerial warfare service branch of the United States Armed Forces and one of the seven American uniformed services. Initially part of the United States Army, the USAF was formed as a separate branch of the military on 18 September 1947 under the National Security Act of 1947.[5] It is the most recent branch of the U.S. military to be formed, and is the largest and one of the world's most technologically advanced air forces. The USAF articulates its core functions as Nuclear Deterrence Operations, Special Operations, Air Superiority, Global Integrated ISR, Space Superiority, Command and Control, Cyberspace Superiority, Personnel Recovery, Global Precision Attack, Building Partnerships, Rapid Global Mobility and Agile.[6]
Vladimir Vladimirovich Putin</media:description><media:keywords/><media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license><media:player url='http://www.youtube.com/watch?v=ou87i6Oq5M0&feature=youtube_gdata_player'/><media:thumbnail url='http://i1.ytimg.com/vi/ou87i6Oq5M0/default.jpg' height='90' width='120' time='00:01:22.500' yt:name='default'/><media:thumbnail url='http://i1.ytimg.com/vi/ou87i6Oq5M0/mqdefault.jpg' height='180' width='320' yt:name='mqdefault'/><media:thumbnail url='http://i1.ytimg.com/vi/ou87i6Oq5M0/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:thumbnail url='http://i1.ytimg.com/vi/ou87i6Oq5M0/1.jpg' height='90' width='120' time='00:00:41.250' yt:name='start'/><media:thumbnail url='http://i1.ytimg.com/vi/ou87i6Oq5M0/2.jpg' height='90' width='120' time='00:01:22.500' yt:name='middle'/><media:thumbnail url='http://i1.ytimg.com/vi/ou87i6Oq5M0/3.jpg' height='90' width='120' time='00:02:03.750' yt:name='end'/><media:title type='plain'
>WORLDS FASTEST propellar driven AIRCRAFT Russian Tu 95MC Nuclear Bomber</media:title><yt:duration seconds='165'/><yt:uploaded>2013-09-01T11:21:22.000Z</yt:uploaded><yt:uploaderId>UCD8bmW4A7eYzHrW7sXwsqwQ</yt:uploaderId><yt:videoid>ou87i6Oq5M0</yt:videoid></media:group><gd:rating average='4.855856' max='5' min='1' numRaters='111' rel='http://schemas.google.com/g/2005#overall'/><yt:statistics favoriteCount='0' viewCount='67834'/><yt:rating numDislikes='4' numLikes='107'/></entry>
Don't worry too much about the complexity. All you need is this element from it:
<media:content
url='rtsp://r8---sn-5hn7su7l.c.youtube.com/CiILENy73wIaGQnN5KqjizvvohMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp'
type='video/3gpp'
medium='video'
expression='full'
duration='165'
yt:format='1'/>
Note that there may be more than one media:content element - you need the one with type=video/3gpp` content type. Take the URL from it - this is the URL of the video stream.
Now use VideoView to show your video:
VideoView video = (VideoView)findViewById(R.id.video_player);
video.setVideoURI(Uri.parse(videoUrl));
video.start();
In this code the videoUrl is the URL as shown above, specifically,
rtsp://r8---sn-5hn7su7l.c.youtube.com/CiILENy73wIaGQnN5KqjizvvohMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp

Related

Webview Content not using full width

I am using a webview to load HTML content in my app.
But text content is not using full width of webview, and it shrinks and wraps.
Below is code I have used:
webView.setInitialScale(1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setBuiltInZoomControls(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
My HTML content doesn't contains meta tag for viewport.
Here is a Screenshot:
Looking forward for help from you guys.
Below is HTML content:
<p><span style="color:#c0392b"><strong>NYSBA Member: $175</strong></span><br /> </p><p><img alt="" src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Google_Images_2015_logo.svg/1200px-Google_Images_2015_logo.svg.png" style="height:250px; width:600px" /><br /> </p><p><span style="font-size:20px"><strong>Estate Planning and Will Drafting 2018</strong></span><br /> </p><p><strong>Program Description</strong></p><p>This full-day program will highlight current estate planning techniques and the means of implementing such techniques through a discussion of drafting of wills and trusts. Attendees will leave this program knowing how to write a basic will. Discussions will also include trusts for minors, charitable trusts, lifetime giving and planning for those with disabilities, tax implications and planning, digital assets, and ethical considerations.</p><p><strong>Who Should Attend</strong></p><p>Attorneys in the general practice of law, estate and trust planners, elder law attorneys, and those interested in a basic knowledge of taxation as it applies to wills and trusts.</p><p><br /><span style="font-size:14px"><strong>Sponsored by the Committee on Continuing Legal Education, the Trusts & Estates Law Section and</strong></span><br /><img alt="" src="{IMAGE URL}" /><br /> </p><p><strong>Live CLE Program & Webcast </strong></p><p>Tuesday, February 6, 2018 – Syracuse Sheraton University Hotel<br />Tuesday, February 6, 2018 - Long Island – Melville Marriott<br />Wednesday, February 7, 2018 – NYC (live webcast) – CFA Society New York<br />Thursday, February 8, 2018 – Holiday Inn Mt. Kisco<br />Thursday, February 8, 2018 - Classics V Banquet Center Buffalo<br />Friday, February 9, 2018 – New York State Bar Association<br />Friday, February 9, 2018 – RIT Inn & Conference Center</p><p><strong>7.0 MCLE Credits: 6.0 Areas of Professional Practice,1.0 Ethics</strong></p><p><strong><span style="color:#c0392b">NYSBA Member:</span> $175 | <span style="color:#c0392b">Non-Member:</span> $275</strong><br /><strong><span style="color:#c0392b">Section Member:</span> $135</strong></p><p><strong>Agenda Topics</strong></p><ul><li>Estate Planning Overview</li><li>Will Drafting Overview</li><li>Planning with Revocable Trusts</li><li>Lifetime Giving, Minors and Incapacitated Beneficiaries</li><li>Tax Implications and Drafting</li><li>Digital Assets</li><li>Ethical Considerations</li></ul><p><span style="color:#c0392b"><strong>Program Chair</strong></span><br /><strong>Patricia Shevy, Esq., </strong>The Shevy Law Firm, Albany</p><p><span style="color:#c0392b"><strong>Local Program Chairs </strong></span><br /><strong>Jennifer M. Boll, Esq.</strong>, Bond Schoeneck & King, PLLC, Albany <br /><strong>Gail M. Boggio, Esq.,</strong> McCarthy Fingar, LLP, White Plains</p><p><strong><span style="color:#c0392b">Buffalo Program Faculty</span></strong><br /><span style="font-size:14px"><span style="font-family:Arial,Helvetica,sans-serif"><strong>Linda Stravalaci Grear, Esq., </strong>Pfalzgraf Beinhauer Menzies, Buffalo<br /><strong>John F. Leone, Esq., </strong>Gross Shuman, P.C., Buffalo<br /><strong>Kenneth Aaron Grossberg, Esq., </strong>Phillips Lytle LLP, Buffalo<br /><strong>William D. Harrington, Esq</strong>., Brown & Kelly, LLP, Buffalo<br /><strong>Catherine B. Eberl, Esq., </strong>Hodgson Russ LLP, Buffalo<br /><strong>Hon. Barbara Howe, </strong>Retired NY State Judge for Erie County, Buffalo<br /><strong>Dennis P. Cleary, Esq., </strong>Duke Holzman Photiadis & Gresens LLP, Buffalo</span></span></p><p><br />Newly Admitted Attorneys: To receive skills credit, newly admitted attorneys must take accredited transitional CLE courses in traditional live classroom settings that have been approved by the CLE Board for use by newly admitted attorneys. For more information about the CLE Rules, please go to www.nycourts.gov/Attorneys/CLE.</p><p>Out of State Accreditation: This program has also been approved for MCLE credit by the State Bar of California, the Pennsylvania Continuing Legal Education Board and the Board of Continuing Legal Education of the State of New Jersey. If you require MCLE credit in other states, we can provide you a Uniform MCLE Form.</p><p>Partial Credit for Program Segments Not Allowed: Under the New York State Continuing Legal Education Board Regulations and Guidelines, attendees at CLE programs cannot get MCLE credit for a program segment (typically, a lecture or panel, of which there are usually several in a program) unless they are present for the entire segment. Those who arrive late, depart early, or are absent for any portion of the segment WILL NOT receive credit for that program segment.</p><p> </p><p><strong><img alt="{IMAGE_URL}" src="{IMAGE_URL}" /></strong></p><p>Follow NYSBA CLE on Twitter! #NYSBACLE</p><p>Stay informed. Be the first to hear about the latest course offerings.</p><p>To view the full list of Continuing Legal Education Programs, click here.</p><p>If you have any questions about this program, please contact staff attorney Sally Bratten. </p><p> </p><p> </p>

How to decode special characters from JSON. (e.g. " ' " to " ' " )

In my CMS I have json responses for different data I insert,and I get them in JSON format.
ie.
[{"id":"7","image":"vangal.jpe","name":"Louis Van Gaal","nationality":"Dutch","managed_from":"14 July 2014",
"article":"Louis van Gaal arrived at Manchester United with an outstanding record of success first in his native Netherlands and subsequently at some of the biggest clubs in the world.\r\n\r\nAs a manager he has won league titles in three different countries, guided a youthful Ajax side to UEFA Champions League glory, as well as lifting the UEFA Cup. His second stint in charge of the Dutch national team ended with the Netherlands making the semi-finals of the 2014 World Cup, a run which included a magnificent 5-1 win over holders Spain.\r\n\r\nBorn Aloysius Paulus Maria van Gaal in Amsterdam on 8 August 1951, he joined Ajax aged 20 and while he never played for the great Dutch club's first team, the influence of the time he spent immersed in its culture of Total Football has never left him.\r\n\r\nHe cut his teeth at professional level after moving over the border to Royal Antwerp in Belgium, but following four years there he returned to Holland to complete his playing career, briefly at Telstar, then for eight years at Sparta Rotterdam before retiring after a short stint at AZ.\r\n\r\nVan Gaal remained at AZ to begin a coaching and management career where the characteristics of fluent passing, talented youngsters being given a chance and canny tactics through a high attention to detail have remained to great effect at the highest level of the global game.\r\n\r\nAfter leaving AZ, van Gaal's coaching education continued under the legendary Leo Beenhakker at Ajax, who he succeeded as first team boss in 1991. The club's fortunes had dipped since the golden era of the 1970s, but under van Gaal Ajax secured three consecutive Eredivisie titles and the UEFA Cup. But more importantly they delivered European Cup success, in its new guise as the Champions League, returning the trophy to the club for the first time in over 20 years.\r\n\r\nA side containing future United star Edwin van der Sar, the De Boer brothers, Frank Rijkaard, Edgar Davids, Clarence Seedorf, Marc Overmars and Patrick Kluivert overcame AC Milan in Vienna, and after this success it was inevitable that van Gaal would be linked with some of the biggest clubs in Europe. He eventually succeeded Bobby Robson at Barcelona in 1997, and after inheriting a set-up that included Jose Mourinho on the coaching staff, his new side won La Liga in his first season in charge, retaining the title the following year.\r\n\r\nWhile at Barca, van Gaal had the first of four meetings with United in the Champions League, handing an 18-year-old Xavi his European debut during the 3-3 draw at Old Trafford. The first goalscorer that night? Ryan Giggs.\r\n\r\nVan Gaal then had spells in charge of the Dutch national side and the Catalan giants again, and following a brief time at Ajax as technical director he returned to AZ and guided them to the Dutch title in 2009.\r\n\r\nThis dramatic success led to Bayern Munich recruiting him, and van Gaal became the first Dutch manager to win the Bundesliga, claiming a league title in his debut season in charge at a club for the second time β something Reds fans would love to see him do again at United.\r\n\r\nA second Champions League final for van Gaal, in 2010, ended in defeat to an Inter Milan side managed by former assistant Mourinho, and after leaving Bayern he took up the reins of the Dutch national side once again and successfully steered them through to the 2014 World Cup finals. The Netherlands won the third place play-off with a 3-0 win over hosts Brazil, but just a few days later van Gaal was officially unveiled in Manchester to begin the next chapter of an already stellar career.\r\n\r\nHis announcement as the next United manager, the club's first continental coach to take charge of the first team, arrived on 19 May 2014. Ryan Giggs was announced as his assistant manager, while assistant coaches Albert Stuivenberg, Frans Hoek (specialising with goalkeepers) and Marcel Bout (focusing on opposition scouting), training physiologist Jos van Dijk and performance analyst Max Reckers also joined a new-look backroom team at Old Trafford.\r\n\r\nVan Gaal, who eventually started work at United on 14 July 2014, said: "It was always a wish for me to work in the Premier League. To work as a manager for Manchester United, the biggest club in the world, makes me very proud. I have managed in games at Old Trafford before and know what an incredible arena it is and how passionate and knowledgeable the fans are. This club has big ambitions; I too have big ambitions. Together I'm sure we will make history.""}]
In this case I have a simple JSON Array with some text in it. However,I can't read some characters from that text like the ' one and "". I hope you can see that from the following screenshot.
How can I take out characters 's? It looks really ugly and hard to read.
Τhanks.
Use like the following
myTextView.setText(Html.fromHtml("ur text here"));
Provided JSON is incorrect, try to parse it using http://jsonlint.com/ first.
If I understand you correctly, you have some issues with ' and ". Try to use \' and \" instead.
Thank you for the replies! Problem is fixed thanks to the user called lal.
myTextView.setText(Html.fromHtml("ur text here"));

Parsing xml only getting CDATA within Tag

I am trying to get text from an xml file that looks like so:
<description>
<p>
<strong>Last updated:</strong>
Mon, 19 Aug 2013 23:52:31</p>
<p>Incident is 53% contained.</p>
<![CDATA[<p>The American Fire burning in heavy fuels on extreme slopes about 10 air miles northeast of the community of Foresthill, California, and eight air miles south of Interstate 80 has grown to 14,765 acres.</p> <p><strong>The public is invited to an American Fire update meeting at the Foresthill Veteran's Memorial Hall at 24601 Harrison Street in Foresthill beginning at 7 p.m. tonight.</strong></p> <p>Heavy smoke shaded the fire yesterday, moderating fire behavior. Backing fire with single and group tree torching was observed. On the northeast corner a spot fire was quickly contained by firefighters as they made good progress with hand lines and dozer lines. Along the eastern portion of the fire last night, firefighters conducted a firing operation, meaning they used fire to reduce unburned fuel between the fire line and the main fire. The center portion of the east flank was still very active during the day, but indirect containment lines remained secure. On the extreme south end, firefighters will begin building a very steep hand line today, which descends to the river. The west side of the fire was relatively inactive. Mop-up is occurring in this area, which involves checking the interior of the fire to ensure no hot spots remain that may threaten the containment lines.</p> <p>Firefighters continue to be concerned about dry fuels that have not seen fire in over a century, as well as any winds over 5 m.p.h. and rolling burning debris, all of which could cause a rapid spread of the fire.</p> <p>The National Weather Service has issued a Red Flag Warning for the fire area beginning at 11 a.m. today and extending through 11 p.m. Wednesday. This Warning is due to the threat of abundant lightning and gusty, erratic outflow winds. Significant rainfall and flooding in and around the fire is also possible over the next three days.</p> <p>The Robinson Flat Campground is closed. The Tahoe National Forest has issued a voluntary evacuation notice for Big Oak Flat located near the south end of the fire. Forest Road 43 (Robinson Flat Road) is closed at its intersection with Forest Road 96 (Mosquito Ridge Road).</p> <p>An emergency closure order is in place for portions of National Forest System lands within and adjacent to the American Fire. A map and description of the closed area can be obtained at Tahoe National Forest offices as well as online at http://www.fs.usda.gov/tahoe. Portions of the Foresthill Divide road are closed.</p> <p><strong>At 6 a.m. today, management of the fire was transferred to the California Interagency Management Team 4.</strong></p> <p>Firefighter and public safety are the highest priority.</p>]]>
<p>
View American Wildfire web site
</p>
<p>
<strong>NOTE: </strong>
All fire perimeters and points are approximations.</p>
</description>
When I parse it, I can get all the information within the CDATA area, but the rest of it is ignored. I am parsing and putting into my text view like so:
description.setText(extras.getString("desc"));
I am using android query and can have it format no problem with this:
aq.id(R.id.description).text(Html.fromHtml(extras.getString("desc")));
However, same issue, just getting the cdata info. My log.v() shows just the info between cdata. So I guess I need to escape it somehow? Why is the text outside of cdata being ignored?
Thanks
Thanks
Just change
if(child.getNodeType() == Node.TEXT_NODE)
to
if (child.getNodeType() == Node.CDATA_SECTION_NODE || child.getNodeType() == Node.TEXT_NODE)
in XMLParser.java file.
I was able to get rid of cdata this way:
for (XmlDom entry : entries) {
XmlDom description = entry.tag("description");
String cdatareplace = description.toString();
String desc = cdatareplace.replace("<![CDATA[", "");
desc = desc.replace("]]>", "");
kmllist.add(new KML(entry.text("name"), desc));
}
Add the entry tag to the variable then use string replace to get rid of the cdata and then show all of the text within the tags. Works fine.

How to parse htmltags in a json in android

I have a json file and one of its Jsonobject contain an html tag.My problem is that i can't parse that json object. How can i do that? Here is the sample for json file
{
"data": {
"insert": [
{
"category": "Fashion",
"blog_title": "Bold Floral Tunic Dress",
"blog_descr": "Get the look of spring’s bold florals with this flowy tunic dress. What we love about it is the bold colors and the hyper-realist print…reminiscent of the work of British designer Mary Katrantzou. Extra bonus? At this price, it’s not just easy to wear - it’s also easy on the wallet.$79.90 at Zara",
"source": "omiru",
"rate": "7.9",
"status": "Active",
"blog_date": "25-04-2012 14:53",
"last_view_date": "11-09-2012 22:19",
"blog": "<p><img class=\"alignnone size-full wp-image-8558\" title=\"bold-floral-tunic-dress_042312\" src=\"http://www.omiru.com/wp-content/uploads/2012/04/bold-floral-tunic-dress_042312.jpg\" alt=\"bold-floral-tunic-dress_042312\" width=\"455\" height=\"583\" /><br /><span style=\"font-size: x-small;\"><br />Get the look of spring’s bold florals with this flowy tunic dress. What we love about it is the bold colors and the hyper-realist print…reminiscent of the work of British designer Mary Katrantzou. Extra bonus? At this price, it’s not just easy to wear - it’s also easy on the wallet.<br /></span><br /><span style=\"font-size: large;\">$79.90</span><span style=\"font-size: x-small;\"> at <span style=\"text-decoration: underline;\">Zara</span>.</span></p>",
"blogid": "218",
"comments": "50"
},
{
"category": "Fashion",
"blog_title": "April 2012 Lookbook: Urban Playground",
"blog_descr": "This look is part of Omiru’s April 2012 Lookbook series, which builds upon our 16-Piece April 2012 Capsule Wardrobe. See more information about this look.We’re dreaming of the carefree days of childhood - of playground games, of laughter and fun, of adventure in the ordinary. But even if your spring days are destined to be",
"source": "omiru",
"rate": "8.1",
"status": "Active",
"blog_date": "25-04-2012 14:53",
"last_view_date": "11-09-2012 22:19",
"blog": "<p><img title=\"Omiru\"s April 2012 Lookbook: Urban Playground\" src=\"http://embed.polyvoreimg.com/cgi/img-set/cid/47694438/id/-wzdDuNKQ5WoEt0claUYLA/size/e.jpg\" alt=\"Omiru\"s April 2012 Lookbook: Urban Playground\" width=\"400\" height=\"400\" border=\"0\" /><br /><span style=\"font-size: x-small;\"><em>This look is part of Omiru’s April 2012 Lookbook series, which builds upon our 16-Piece April 2012 Capsule Wardrobe. See more information about this look.</em>We’re dreaming of the carefree days of childhood - of playground games, of laughter and fun, of adventure in the ordinary. But even if your spring days are destined to be spent in a metropolis, you need not lose the playfulness in your style. For the urban playground, keep the simple silhouettes - updating them with more sophisticated fabrics, patterns, and colors. Also keep your sense of serendipity and wonder - which will help you navigate the urban playground just as well as you ruled the neighborhood playground way back when.1. Start with a chic but comfortable foundation: an oversized cropped tee paired with a buttery pair of knee length leather shorts. The cropped tee works with the high rise on the short and calls attention to the leg-lengthening silhouette.<br />2. Enough black and white with this foundation - it’s time to add color! Toss on a cardigan in a bright yellow to offset the black and white of the tee and shorts. Bonus points for toting around a handbag in a complementary bright color - notice how the turquoise bag adds an extra dimension to the yellow, black, and white of the look.<br />3. Finish off the look with accessories with an edge - a pair of studded gladiator sandals, a leather wrap bracelet with a skull motif, and a retro chic pair of sunglasses. <br /><strong><br />What do you wear to navigate the urban playground?</strong> Share your style in the comments!<br /></span></p>",
"blogid": "219",
"comments": "53"
},
{
"category": "Food",
"blog_title": "Lai Kee Dim Sum: Novel bits and bites",
"blog_descr": "Dim Sum $1.80 to $2 per basketThere are several hawker genres that should do well in Singapore and Dim Sum is one of them. The reason is very simple. Every customer will spend more than $3-4 per pax. If you survey the current hawker scene, you will see Bak Kut Teh stalls springing up all over the place. That is because",
"source": "ieatishootipost",
"rate": "8.1",
"status": "Active",
"blog_date": "25-04-2012 14:53",
"last_view_date": "11-09-2012 22:19",
"blog": "<p><img src=\"http://3.bp.blogspot.com/-ETJZGZWwUW8/T4ZVSwz5ymI/AAAAAAAAR8Y/YwZutmTZwkU/s800/Siew+Mai.jpg\" alt=\"\" width=\"500\" height=\"332\" border=\"0\" /><br /> <span style=\"font-family: Arial,Helvetica,sans-serif; font-size: x-small;\"><em>Dim Sum $1.80 to $2 per basket</em></span><br /> <br /> There are several hawker genres that should do well in Singapore and Dim Sum is one of them. The reason is very simple. Every customer will spend more than $3-4 per pax. If you survey the current hawker scene, you will see Bak Kut Teh stalls springing up all over the place. That is because people expect to pay $5-6 at least when they eat Bak Kut Teh. So that is going to ensure the survival of Bak Kut Teh as a Hawker dish. Things like Char Kway Teow which can only sell for $3 a plate is less attractive for any aspiring hawker to take on so unless something happens and a Char Kway Teow emerges that people are willing to pay $6 for, then it really is \"The End of Char Kway Teow\" as we know it.<br /> <br /> But today we talk about an emerging Hawker dish. I guess Dim Sum is not really what people will consider a traditional Hawker food, but with increasing affluence, stalls which were initially selling only Paus would invariably be attracted to increasing their revenue by offering other Dim Sum dishes. With Dim Sum at the restaurants now averaging around $4-$5++ a basket, I see a big opportunity for more hawkers to offer a cheaper alternative in a coffeeshop setting.<br /> <br /> The other good thing about Dim Sum is that the food can be standardized and prepared in a central kitchen beforehand and steamed fresh at the premises when you order. So that allows for opportunities to expand. At $2 a basket, the average spend for a customer would be at least $8-$10 which essentially triples what you would earn if you sell Char Kway Teow!<br /> <br /> With more hawker Dim Sum emerging and restaurant Dim Sum getting ridiculously expensive, I am hoping to see more stalls such as Lai Kee emerging so that we can all spend a lazy morning drinking eating Dim Sum and drinking Teh C without having to pay for peanuts and ++. So, if you know of any good hawker Dim Sum stalls, please do write in and let me know so that I can build a list good Dim Sum stalls to visit.<br /> <br /> <img src=\"http://2.bp.blogspot.com/-J6lTLrdcqqw/T4ZVRLQgi6I/AAAAAAAAR8I/WWPwy_s1W4c/s800/Dim+Sum+Selection.jpg\" alt=\"\" width=\"500\" height=\"500\" border=\"0\" /><br /> <span style=\"font-size: x-small;\"><span style=\"font-family: Arial,Helvetica,sans-serif;\"><em>Variety of Dim Sum</em></span></span><br /> <br /> The man who started Lai Kee, Ah Lai started off helping to make Dim Sum with relatives in Malaysia before coming out to Singapore to start his own stall. His first stall was at Clementi and has now expanded to four branches. He tells me that Dim Sum might be more lucrative but it is a lot of hard work. Now that he has four stalls, he has hired a few Dim Sum chefs to help hand make the Dim Sum every day at the stalls while he prepares the meat, prawn and fish pastes centrally.<br /> <br /> What I like about Lai Kee is their variety of unusual Dim Sum. The standard fare of Siew Mai and Har Kau are of course available and judging from the Siew Mai, the basic meat filling is very good and well marinated. Ah Lai pays special attention to this and uses only fresh Indonesian pork instead of frozen meat to ensure quality. But he has spent a lot of time thinking up new dishes as well and the wonderful thing about eating there is that you get to try something new instead of the same-o same-o.<br /> <br /> I was drawn immediately to the Century Egg dumplings because they reminded me of the marvelous breakfast I had at Sim Sim Pier in Sandakan. Then there are other permutations and combinations of tasty morsels made from tofu, bean curd skin, meat, prawn and fish filling. I can\"t say that it tastes as exquisite as the Dim Sum you get at the restaurants, but the affordability, variety and pretty decent food quality certainly makes it a compelling candidate for a quick Dim Sum fix.<strong><span style=\"color: red;\"> 4/5</span></strong><br /> <br /> <br /> <img src=\"http://2.bp.blogspot.com/-_t2-e91Hjmc/T4ZVSD9tupI/AAAAAAAAR8M/HACNNC88564/s800/Lo+Mai+Pau.jpg\" alt=\"\" width=\"332\" height=\"500\" border=\"0\" /><br /> <span style=\"font-size: x-small;\"><em>鸡窝包</em><em> Ji Wo Pau (Chicken Nest Pau)$3</em></span><br /> <br /> <strong>Conclusion </strong><br /> <br /> With prices of Dim Sum in restaurants going through the roof, coffeeshop Dim Sum places like Lai Kee are offering us an attractive, affordable alternative. I do hope to blog more such stalls, so do write in if you know of any stalls that are serving up good, affordable Dim Sum! <br /> <br /> </p>\r\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><a style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\" href=\"http://4.bp.blogspot.com/-HTyoS60oDAk/T4ZVUrXe3rI/AAAAAAAAR8g/4o-6bbVAS5I/s1600/Stall.jpg\"><img src=\"http://4.bp.blogspot.com/-HTyoS60oDAk/T4ZVUrXe3rI/AAAAAAAAR8g/4o-6bbVAS5I/s200/Stall.jpg\" alt=\"\" width=\"200\" height=\"132\" border=\"0\" /></a></div>\r\n<p>Lai Kee Pau<br /> Blk 69 Bedok South Ave 3<br /> 6.30am and 9.30pm<br /> 90261698<br /> Branches: Clementi St 12, Blk 107 <br /> Bukit Batok St 21 Ave 6, Blk 207</p>",
"blogid": "220",
"comments": "51"
}
],
"lastid": "63"
},
"status": 1
}
Anyone please help me..
If you want to display HTML, you can use a WebView. If you need limited support for basic HTML tags, you can use Html.fromHtml

How to get Values from HTML String in Android

I have a problem that I want to get different values from different tags from HTML String as, <p><div class=\"image_wrapper\" style=\"width:320px;\"><img name=\"tccimg_100322484_s\" **title=\"2011 Chevrolet Corvette 2-door Coupe Z06 w/2LZ Angular Front Exterior View\"** src=\"http://images.thecarconnection.com/sml/2011-chevrolet-corvette-2-door-coupe-z06-w-2lz-angular-front-exterior-view_100322484_s.jpg\" alt=\"2011 Chevrolet Corvette 2-door Coupe Z06 w/2LZ Angular Front Exterior View\" width=\"320\" height=\"240\" /><p>2011 Chevrolet Corvette 2-door Coupe Z06 w/2LZ Angular Front Exterior View</p><a name=\"tccwrp_100322484\" class=\"enlarge\" href=\"/image/100322484_2011-chevrolet-corvette-2-door-coupe-z06-w-2lz-angular-front-exterior-view\" target=\"_blank\">Enlarge Photo</a></div></p>\n<p>The Chevrolet Corvette is an American icon: a rear-wheel drive, two-seat sports car that started its legendary run in 1953 and has seen 57 years of continuous production in Flint, Michigan, St. Louis, Missouri and most recently in Bowling Green, Kentucky. Over the years it has constantly evolved to lead performance and value, with occasional lows and numerous highs along the way. Though it has little domestic competition, cars as disparate as the Dodge Viper, Porsche Boxster and 911, and the Nissan GT-R and 370Z can be considered rivals in terms of performance and/or price. The Chevrolet Corvette is priced from $48,000 to $56,000 for the standard Coupe and Convertible, from $58,000 to $68,000 for the Grand Sport, from $75,000 to $82,000 for the Z06, and from $106,800 for the ZR1.</p>\n<p>Over the past 57 years of production, there have been six generations of Corvette. The first 1953 models featured solid rear axles and inline six-cylinder engines, though in 1955, the V-8 became standard. When the second generation \"Sting Ray\" debuted in 1963, independent rear suspension was added and output was increased to 360 horsepower. A big-block 6.5-liter model was added in 1965, before the famous 427 cubic inch (7.0-liter) engine joined in 1966. The third-gen car began its run in 1968, running for 13 years until 1982--the longest run of the various Corvette generations. The new, fender-flared body style was the primary new addition to the line, along with a three-year run for the ZR-1 performance edition, though emissions and fuel regulations conspired to restrict power output and potential of Corvettes throughout the 1970s. The fourth-generation Corvette hit the street in 1983 as a 1984 year model, bringing with it a complete redesign of the car aside from the engine, with a sleek, modern design and digital instruments, and the second ZR-1 performance version. The fifth-gen car, introduced in 1997, saw another major upgrade, with improved build quality, more performance, and better handling the result. The Z06 model was introduced in 2001, and engines continued to be upgraded, producing 405 horsepower in the Z06.</p>\n<p>The sixth and current Corvette generation debuted in 2005, and brought with it all new bodywork and improved suspension. Power climbed to 400 horsepower for the base Corvette initially, now up to 430 horsepower from its 6.2-liter V-8 LS3 engine, and 505 horsepower for the current 7.0-liter Z06. The ZR1 was added back to the lineup in late 2007 as a 2008 year model, producing 638 horsepower from a supercharged 6.2-liter V-8 engine. Currently available in Coupe, Convertible, a Grand Sport version with upgraded brakes and special bodywork, the high-performance Z06, and the supercar-rivaling ZR1.</p>\n<p>The Coupe and Convertible are the standard Corvettes, with 430 horsepower output and all the conveniences of a modern car, including available Bluetooth on some models, a choice of six-speed manual or automatic transmission, and available leather interior. The Grand Sport is also available as both a coupe and convertible, though the coupe gets a few performance upgrades over the soft top, including a dry-sump oil system when equipped with the six-speed manual transmission, plus the upgraded brakes and flared fenders that both variants get. The Corvette Z06 ups the performance ante with extensive use of carbon fiber body panels and components, an aluminum frame, and a 505-horsepower engine. The ZR1 is king of the hill, its massive power output combined with Brembo ceramic carbon brakes, visible carbon fiber weave components, and a 205-mph top speed. Despite their huge power and impressive performance figures, the brawny engines in the Corvette enable it to achieve up to 26 mpg on the highway.</p>\n<p>No major changes were made for the 2012 model year, though the range did get interior updates, new technology packages, and a range of new exterior colors. High-performance Z06 and ZR1 models also got new performance packages.</p>\n<p>For 2013, a new 427 Convertible Collector Edition has been added, pairing the Z06's LS7 V-8 engine with a Corvette Convertible chassis and unique 60th Anniversary touches. A 60th Anniversary Package will also be available on all 2013 model Corvettes, adding a special touch to celebrate six decades of the Corvette. The rest of the line carries forward largely unchanged from last year.</p>\n<p>The next major generational upgrade is expected to come in late 2013, with the seventh-generation car drawing on GM's global resources for its new design--the first time the Corvette team has looked outside the U.S. for the iconic 'Vette.</p>\n"
I want to get Image title value from this html string in the starting, but I am unable to get that. I am using Jsoup for parsing of this HTML String as,
Code:
Document doc = Jsoup.parse(html);
Elements element = doc.getAllElements();
for(Element e: element)
{
Elements str = e.getElementsByTag("img");
for(Element el: str)
{
String title = el.getElementsByAttribute("title").text();
System.out.println("The Title:"+title);
}
}
Please suggest me any solution regarding the same.
Thanks in advance.
Replace the following line:
String title = el.getElementsByAttribute("title").text();
with
String title = el.attr("title");
Explanation: the function call getElementsByAttribute("title") will return a List of Elements (see Jsoup Doumentation - Element), when really you just want to look at the attribute for a specific element. See also Jsoup Documentation - Node.

Categories

Resources