News

News

Sony’s Android Auto aftermarket head unit on sale now for $499

0

If you are looking to add full support for Android Auto inside your current vehicle, there’s a new option available. The Sony XAV-AX100 aftermarket car head unit, which supports both Android Auto as well as Apple’s CarPlay, is now available to purchase for $499 at Amazon.

See also:

Android Auto: everything you need to know

August 3, 2016

The price tag for the Sony unit is definitely on the lower side of these aftermarket car entertainment solutions; usually they sell for between $800 to $1,500. One of the reasons why this Sony version may be so cheap is that it uses a less advanced resistive touch screen, rather than the capacitive supported displays that are more common in smartphones.  One thing it does have is a physical rotary dial on the left side to control volume and other features without having to use the touch screen.

Some of the other features included with the Sony XAV-AX100 are the ability to create virtual speakers on the dashboard with the Dynamic Stage Organizer, and the 4 x 55 W Dynamic Reality Amp, which the company says offers users clear sound, even at high volumes. Amazon’s listing states that shipments of the unit will begin sometime before Christmas, but a specific date was not posted.

Get it at Amazon

Xiaomi may be expanding into more global markets; here’s why that’s important

0

China-based Xiaomi may have become one of the biggest smartphone makers in the entire world, but so far its devices are only officially sold in a few markets. That may be changing soon, according to new rumors about the company expanding its global presence.

See also:

Going into 2017, these are the Chinese smartphone makers to look out for

1 week ago

According to the Czech site SvětAndroida. the company is preparing to launch global versions of its Redmi 4A, Redmi 4 and Redmi Note 4 phones before the end of 2016. Another report, this time from Android Headlines, claims that Xiaomi could begin selling its phones in Greece later in December. Obviously both of these stories have not been confirmed by Xiaomi, so take them with a grain of salt.

The company sells the majority of its phones in China, India and a few other Asian countries and territories, but it has expanded slowly into other markets like Brazil and South Africa. This is likely only the beginning.

For starters, Xiaomi has confirmed it will be making its first appearance at the big Consumer Electronics Show in Las Vegas in January, for the launch of a new, but unnamed product, that will be available globally. It is also very possible this ‘global’ launch could include the US. Xiaomi has made extremely slow strides in the coveted US market so far, but certainly has expressed interest in the states. Last year it began its push into the US with its Mi accessory store, and earlier this year the company began selling its Android TV-based set-top box, the Mi Box, via Walmart for just $69.

Even more recently, the company has confirmed it is in the middle of testing some of its phones on US carriers, which could lead to an official smartphone launch in late 2017.

Why now is the right time to push into the US

Xiaomi may be expanding into more global markets; here’s why that’s important

All of these developments come as Xiaomi’s status as the number one smartphone company in China has been toppled by rivals Vivo and OPPO in recent months. With increased competition in China, it makes a ton of sense for the company to look beyond its current borders and markets as it tries to get back on top. In fact, the lower sales in China may help to encourage Xiaomi to move much faster in offering its devices to more countries, including the US.

See also:

Best Chinese Android phones

November 9, 2016

Xiaomi may also want to move quickly because it makes phones that are both affordable but also have high-end hardware and features. In the last year or so the US market has seen a number of players get into the affordable-yet-premium game. Xiaomi has shown that it knows how to excel in this area, and if it can actually win carrier support, this could give the company a leg up when compared to other rival ‘affordable flagship’ brands like Honor, Huawei, ZTE, and OnePlus.

Samsung’s still recent recall of the Galaxy Note 7 could also make it vulnerable for another company to swoop in and take some of its US market share away, something that its main US rivals have yet to do.

But it won’t be easy

Xiaomi may be expanding into more global markets; here’s why that’s important

Of course, the road to a bigger global presence will also be filled with obstacles as well. Xiaomi is based in China, and there are a lot of fears (many of them unjustified) that the country’s government is using phones to spy on others. That could cause lawmakers to make moves to keep Xiaomi’s products out of the country. There’s also the fact that US wireless carriers sometimes have some odd network protocols that are not followed by the rest of the world. That may be why why Xiaomi is testing its phones in the country now, months ahead of a possible launch in the United States.

Finally, there’s the simple fact that Xiaomi does not have the brand marketing that other, more established, companies have in the US and around the world. Even Sony, one of the world’s biggest and most well know electronics companies, has not had a lot of success selling its Xperia smartphones. Xiaomi will have to make a huge push to educate he US consumer about why its smartphones should be considered alongside its many, many competitors.

Recently, Xiaomi’s  Global VP Hugo Barra was quoted as saying, “We could sell 10 billion smartphones and we wouldn’t make a single dime in profits.” We are not sure if that’s really true, or if he was just making a statement to blow off the company’s lower sales of its phones. More likely, the truth is somewhere in between. Xiaomi may not make a lot of money from smartphones, but at the moment, those products are the flagship devices of its company, and it needs to boost both sales and markets to make itself a bigger overall force in the industry.

Would you like to see Xiaomi phones sold in more countries, including the United States? Do you think the company can find success globally? Let us know your thoughts in the comments!

Will anyone be sad to lose Samsung’s physical home button?

The physical home button is a smartphone facet that’s slowly becoming extinct. In 2016, the flagship devices from Google, Sony, LG, and Huawei all lacked such a button on their hardware. Meanwhile, Samsung has been holding onto the physical home button – it was still in place on its most recent flagship, the ill-fated Galaxy Note 7 – though the company is expected to ditch it on its upcoming flagship, the Galaxy S8. But what impact will losing physical home buttons have? To answer that, let’s first explore its origins.

The move to touchscreens

Though it wasn’t the first device to make use of a touchscreen, much can be attributed to the original iPhone for popularizing it. When numbers and letters could be drawn on a display, there was no longer a need for a traditional keyboard setup, meaning screens were able to occupy a larger space on the handset without increasing the size of the body overall. What’s more, the keys could be contextual: when using the dialer, for example, they could act as large numbers. For emails, a traditional QWERTY keyboard could appear.

Though it lost most of the buttons found on prior handsets, the iPhone would feature a power button, volume controls and a physical home button, plopped front and bottom center of the handset. Pressing this would return users to the iPhone’s home screen – hence its name – no matter which folder or app they were currently in, thus eliminating the need to repeatedly hit a return or back button to jump to the main part of the interface.

Will anyone be sad to lose Samsung’s physical home button?

It’s a setup that would prove popular. So popular, in fact, that the home button placement and function seen on the iPhone are still used today on almost every smartphone. However, its existence as a physical entity is not a steadfast requirement and, perhaps, is no longer even desirable.

Go soft or go home

There are a handful of different approaches to the home button commonly in use today. There’s the “clickable” version found on Samsung’s Galaxy phones, the fixed recess like OnePlus uses, the capacitive buttons which sit off-screen as on the ZTE Axon 7, and then software buttons found on recent Google, Sony, and LG phones.

Software home buttons, which typically replace hardware home buttons at the center of the display, are used by many manufacturers for several reasons. One: mass-manufacturing hardware costs more than software; so when the function of a home button can be included as part of the software, companies can avoid unnecessary production costs. Two: it’s difficult to damage virtual buttons in the same way as physical buttons, by which I mean a software home button won’t wear out over time or be destroyed after an unfortunate fall like a physical one might.

Three: home buttons require space on the handset – space which could instead be used by the display. Just as Apple did with the original iPhone, manufacturers are still trying to optimize the screen-to-body ratios of smartphones (see the recent Xiaomi Mi MIX and the Huawei Mate 9 for good examples of this). Samsung is currently rumored to be aiming for a 90 percent screen-to-body ratio on its Galaxy S8; dropping the home button will go some way to helping it achieve that.

Will anyone be sad to lose Samsung’s physical home button?

So, when removing physical home buttons could result in lower-cost handsets, with larger screen-to-body ratios, featuring one less thing that could break, why would anybody still want one?

Feeling at home

There’s a reason why modern gaming console controllers vibrate, and why modern e-reader apps have page turning animations, and why smartphones have haptic feedback, even when none of these features are critical to functionality. Humans like tactile sensations – and they also like what they know.

Pressing buttons was once necessary to make physical processes happen, we applied force to keys on a typewriter so that they hammered against the paper. Now, designers are seeking to deliver sensory feedback even when it’s not critical.

In the iPhone 7, for example, a hardware home button is in place, but whereas it used to physically depress on previous iPhones, it now only simulates the feeling of being pressed. This is achieved through Apple’s Taptic Engine, which can effectively recreate a number of sensations, but what’s interesting is that the home button doesn’t actually need this feature to work – you could use the home button more-or-less the same without receiving physical feedback.

Will anyone be sad to lose Samsung’s physical home button?

The experience of pressing a physical home button, then, is arguably more satisfying than pressing a software one, in a similar way to how turning a physical page is more desirable to the on-screen equivalent (as much as engineers try to find ways to mitigate this).

But there are functional advantages to the physical home button too. Double pressing the home button to activate the camera as you can on Samsung phones is often more responsive because your body understands when the second press must land – it’s right after that first click. You might not even be conscious of it, it’s automatic. What’s more, a hardware home button is easier to find without looking at the display as it can be located by your fingertips.

Alas, these qualities may not be enough to keep the physical home button alive.

Bright as a button-less future

As manufacturers chase bigger displays on smaller handsets, perhaps it’s only a matter of time before the physical home button becomes a thing of the past (Samsung is even said to be working on a touch-display solution to fingerprint scanning, typically combined in its home buttons).

The physicality of the home button may be desirable – but there are limits to the value these qualities have. BlackBerry recently reintroduced a physical keyboard in its Priv device, however, despite the feeling and function it re-introduced, demand for it was reportedly low and BlackBerry will release its final QWERTY keyboard-equipped device in the near future.

Ultimately, the prospect of bigger displays will likely hold more appeal in the minds of consumers than the benefits of the physical home button, especially when its software alternative is already widely adopted.

I won’t miss them, but where do you stand on physical home buttons? Let me know your thoughts in the comments.

More phones on Sprint add RCS support for Google Messenger

In November, Google confirmed that Sprint would be the company’s first wireless carrier partner to offer Android customers its universal Rich Communications Services (RCS) support. This week, Sprint has quietly added more phones that support RCS with the latest version of Google Messenger.

See also:

What is RCS messaging and why is it important?

November 4, 2016

According to user posts on Reddit, RCS support in Google Messenger has been spotted working on the Moto G4 Play, the LG V20, the LG G4 and the Nexus 5X. Previously, RCS support was limited to the Google Pixel and Pixel XL phones that were set up on Sprint’s network. The Reddit posts note that RCS support seems to be hit and miss on these new phones, so your mileage may vary.

RCS is supposed to be the next generation messaging protocol, replacing the older SMS and MMS standards. It supports features such as group chat, high-res photo sharing, read receipts, and more. Google already announced that all Android devices on Sprint will come with Messenger for Android preloaded as the default messaging experience starting sometime in 2017.

If you own one of the above phones on Sprint’s network, is Google Messenger enabled with the new “enhanced messaging” features?

Samsung Galaxy S7 and S7 Edge will jump straight to Android 7.1.1 Nougat

The Galaxy S7 and S7 Edge will forgo Android 7.0 and be upgraded straight to Android 7.1.1, Samsung has revealed. Samsung made the announcement in a response to a member of the Galaxy beta program who suggested that it upgrades the phones to the latest Android software, and provides a double-tap-to-wake function.

Samsung launched the beta program for the Galaxy S7 and S7 Edge in November to gather feedback on early builds of Android Nougat. The devices are currently running Android 6.0.1 Marshmallow, but Samsung is expected to officially update them to Nougat in early 2017.

See also:

Fourth Galaxy S7/S7 Edge Nougat beta adds Samsung Pass and Note app

2 days ago

Android 7.1.1 Nougat is the latest version of Android, announced by Google on December 5. The update – which delivers new features like app shortcuts and new emoji – is currently available for Nexus and Pixel devices, while third-party manufacturers now have access to the source code via the Android Open Source Project.

Meanwhile, Sony announced yesterday that it planned to be the first manufacturer, other than Google, to deliver Android 7.1.1 to one of its smartphones.

Verizon won’t be rolling out Samsung Galaxy Note 7 shutdown update

Earlier today, Samsung confirmed that it will issue an update on Dec. 19 to all remaining Galaxy Note 7 phones in the US. The update will prevent the  device’s battery from charging, which will of course make the phone useless. As it turns out, one major US carrier won’t be rolling out that update: Verizon Wireless.

See also:

Why Samsung would be crazy to kill the Galaxy Note brand

October 27, 2016

In a statement, Verizon said the reason for its decision was that it feels Samsung’s update will put the few remaining Note 7 owners at “added risk” if they cannot quickly switch to another phone. It added:

We will not push a software upgrade that will eliminate the ability for the Note7 to work as a mobile device in the heart of the holiday travel season. We do not want to make it impossible to contact family, first responders or medical professionals in an emergency situation.

Verizon notes that the “vast majority” of its Note 7 owners have already turned in the recalled phone for another model and repeated its call for all those users to “immediately stop using their devices” and turn them in or exchange it for another phone. It’s very interesting move on Verizon’s part, and it makes sense they don’t want any of their users to be stranded if the Note 7 is their only phone. Then again, these users have been warned multiple times that they should return the phone, so some might argue that this update is necessary in order to get the remaining hold-out users onboard.

 

If you are a Note 7 owner with Verizon, how do you feel about the carrier taking a stand against offering Samsung’s shutdown update?

CM 14.1 rolling out for the 2014 Moto X, Galaxy S3, HTC One Max and more

The incessant CM 14.1 rollout continues unabated, with a big bunch of new supported devices added to its warm Nougat embrace. CM 14.1 is based on Android 7.1 Nougat, delivering the latest and greatest Android has to offer with some CyanogenMod specialties on top to devices that would otherwise languish back on Lollipop or worse.

Nightlies are now available for the following devices: Verizon Galaxy S3 (D2VZW); international Galaxy S3 (I9300); Verizon HTC One Max (T6VZW); HTC One Max (T6); LG G3 (Canada)(D852); Moto X 2014 (Victara); Redmi Note 3 (Kenzo); Redmi 3/Prime (ID0); Xiaomi Mi Max (Hydrogen); BQ Aquaris E5 4G (Vegetalte); Oppo N3 (N3); Oppo Find 7a (Find7); Oppo Find 7s (Find7s).

To download the firmware and CyanogenMod recovery, just hit the CM Downloads page and look for your device’s codename on the left. When CM 14 dropped, Steve Kondik said CM was pushing for a return to its community-driven roots. With this level of support for various aging devices, they’re certainly on the right track for regaining any fans they might have lost along the way.

When was the last time you flashed CyanogenMod? Will you be jumping on CM 14.1?

ZTE offers Nougat preview program for Axon 7 owners in the US

Got a ZTE Axon 7? Live in the US? Fancy a bit of Nougat preview action? If your Axon 7 model number is A2017U then you’re eligible to apply for ZTE’s Nougat preview program for U.S. residents.

You’ll have to be a member of the Z-Community to apply, but signing up for that is a simple enough affair. Then just head to the link below, check the box at the bottom and fill in the application form. It’s unclear how fast you might receive access to the preview, but if you’re interested in giving it a shot, here’s the link.

APPLY FOR AXON 7 NOUGAT PREVIEW

The official Android Nougat update for the Axon 7 isn’t expected until some time in early 2017 (if you believe ZTE Germany, it’s scheduled for January). But the exact rollout date will likely depend on how smoothly the beta program goes and how many bugs need to be ironed out before going public.

Building a simple RSS reader – full tutorial with code

For this Android developer tutorial, we are going to create a simple RSS reader app. This app would fetch RSS feeds from a single, user specified internet address, and display the contents using a RecyclerView. If you aren’t familiar with the RecyclerView widget, check out our previous tutorial on using a RecyclerView.

RSS, or Rich Site Summary, is an easy and efficient way to share snippets of frequently updated information such as blog entries or news items with subscribers. Almost every news website today has an RSS feed, and these feeds can be accessed through dedicated readers or through your favorite browser. An RSS feed usually contains a summary of the new content, rather than the entire news (or blog) article. To answer your question, yes, Android Authority has an RSS feed, available at http://feed.koimoi.com.pk/, and you should subscribe, if you haven’t already. :D

Sample RSS Feed

An RSS feed is a plain text document, formatted in XML. Being XML, it is relatively easy for humans to read, and also not difficult for programs to parse. A sample XML document is shown below.

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>RSS Title</title>
<description>This is an example of an RSS feed</description>
<link>http://www.example.com/main.html</link>
<lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>
<ttl>1800</ttl>
<item>
<title>Example entry</title>
<description>Here is some text containing an interesting description.</description>
<link>http://www.example.com/blog/post/1</link>
<guid isPermaLink="true">7bd204c6-1655-4c27-aeee-53f933c5395f</guid>
<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>
</item>
<item>
<title>Second example entry</title>
<description>More text containing even more interesting description.</description>
<link>http://www.example.com/blog/post/2</link>
<guid isPermaLink="true">7a4a56b6-1655-4c27-aeee-33e4453f2675</guid>
<pubDate>Sun, 06 Sep 2009 18:14:00 +0000</pubDate>
</item>
</channel>
</rss>

We can see from the sample above, the feed has a title, a description, link, last build date, a publish date and a time to live. For this tutorial, we are only interested in the title, description and link.

There are also two items in the feed, and each has a title, a description and a link, along with a guid (globally unique identifier) and publish date. Most feed items have other tags, but, for our simple RSS  reader, we are only concerned with the title, description and link.

Preparing the project

Of course, the first thing we will do is create a new Android Studio project with an empty activity, which we’ve named SimpleRSSReader. In the AndroidManifiest.xml file, we include the INTERNET permission. Since the rss reader will fetch feeds from the internet, we must declare this permission.

<uses-permission android:name="android.permission.INTERNET" />

Also, we intend to use the support library, RecyclerView and design support library, so we add those to our app build.gradle file. The latest version as at publication is 25.0.1.

    compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:design:25.0.1'

Great. With the initial setup complete, let’s get to work.

Design the layout

For our simple app, we want the user to enter a target RSS feed url, and when he clicks a button, our rss reader app will fetch the feed and display the feed items in a recyclerview.

Building a simple RSS reader – full tutorial with code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.sample.foo.simplerssreader.MainActivity">
<Button
android:id="@+id/fetchFeedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="Fetch" />
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_toStartOf="@id/fetchFeedButton"
android:hint="Rss feed source">
<EditText
android:id="@+id/rssFeedEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/feedTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textInputLayout"
android:text="Feed Title: " />
<TextView
android:id="@+id/feedDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/feedTitle"
android:text="Feed Description: " />
<TextView
android:id="@+id/feedLink"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/feedDescription"
android:text="Feed Link: " />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/feedLink"
android:layout_marginTop="@dimen/activity_vertical_margin">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>

Building a simple RSS reader – full tutorial with code

Did you notice that we enclosed our recyclerview within a SwipeRefreshLayout? A SwipeRefreshLayout is a design support library widget that allows users pull down to refresh, and shows a nice circular progress bar.

Building a simple RSS reader – full tutorial with code

Creating the MainActivity

Within the MainActivity class, the first thing we do is define references to the EditText, the Button, RecyclerView and SwipeLayout. We also setup a click listener for the Button, and an OnRefreshListener for the SwipeRefreshLayout.

public class MainActivity extends AppCompatActivity {
private RecyclerView mRecyclerView;
private EditText mEditText;
private Button mFetchFeedButton;
private SwipeRefreshLayout mSwipeLayout;
private TextView mFeedTitleTextView;
private TextView mFeedLinkTextView;
private TextView mFeedDescriptionTextView;
private List<RssFeedModel> mFeedModelList;
private String mFeedTitle;
private String mFeedLink;
private String mFeedDescription;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mEditText = (EditText) findViewById(R.id.rssFeedEditText);
mFetchFeedButton = (Button) findViewById(R.id.fetchFeedButton);
mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
mFeedTitleTextView = (TextView) findViewById(R.id.feedTitle);
mFeedDescriptionTextView = (TextView) findViewById(R.id.feedDescription);
mFeedLinkTextView = (TextView) findViewById(R.id.feedLink);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mFetchFeedButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new FetchFeedTask().execute((Void) null);
}
});
mSwipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new FetchFeedTask().execute((Void) null);
}
});
}
}

Both the Button and SwipeRefreshLayout perform the same action, which is to start a new FetchFeedTask. The FetchFeedTask is an AsyncTask, which allows us perform possible long running tasks in a background thread. If you try to fetch feeds from a url on the main thread, your app will become unresponsive, and can appear to the user to have stopped working. Ever since Ice-cream Sandwich, Android no longer allows apps make network calls on the main thread. For a refresher on using AsyncTask, you can check out our previous article that discussed how to use a web API from your Android app.

The FetchFeedTask has three simple methods:

  1. onPreExecute, which is called before the long running task starts, and is executed on the calling thread.
  2. doInBackground, which is the long running task, and is executed in a new thread
  3. onPostExecute, which is called after the long running task is complete, and is executed on the calling thread.

Since Android allows manipulation of UI elements (Buttons, SwipeRefreshLayout, etc) only on the UI/Main thread, we can update the UI both in onPreExecute, and onPostExecute, but not in doInBackground.

private class FetchFeedTask extends AsyncTask<Void, Void, Boolean> {
private String urlLink;
@Override
protected void onPreExecute() {
mSwipeLayout.setRefreshing(true);
urlLink = mEditText.getText().toString();
}
@Override
protected Boolean doInBackground(Void... voids) {
if (TextUtils.isEmpty(urlLink))
return false;
try {
if(!urlLink.startsWith("http://") && !urlLink.startsWith("https://"))
urlLink = "http://" + urlLink;
URL url = new URL(urlLink);
InputStream inputStream = url.openConnection().getInputStream();
mFeedModelList = parseFeed(inputStream);
return true;
} catch (IOException e) {
Log.e(TAG, "Error", e);
} catch (XmlPullParserException e) {
Log.e(TAG, "Error", e);
}
return false;
}
@Override
protected void onPostExecute(Boolean success) {
mSwipeLayout.setRefreshing(false);
if (success) {
mFeedTitleTextView.setText("Feed Title: " + mFeedTitle);
mFeedDescriptionTextView.setText("Feed Description: " + mFeedDescription);
mFeedLinkTextView.setText("Feed Link: " + mFeedLink);
// Fill RecyclerView
mRecyclerView.setAdapter(new RssFeedListAdapter(mFeedModelList));
} else {
Toast.makeText(MainActivity.this,
"Enter a valid Rss feed url",
Toast.LENGTH_LONG).show();
}
}
}

In the code snippet above, you can see that we only update the UI in onPreExecute and onPostExecute, while all the computation is done within doInBackground. We define FetchFeedTask as an inner class in MainActivity, so that we can access the MainActivity layout widgets.

In doInBackground, we first confirm that the url entered is not empty, then we add a ‘http://’ to the url if the user left it out. The next step is to open a url connection, using the url.getConnection().getInputStream() method. Finally, we call a method named parseFeed() to parse the resulting RSS feed.

Parsing the RSS feed

Thankfully, android contains some utility classes and interfaces to handle XML parsing. For our rss reader, we will use an XmlPullParser instance to handle parsing the feed. XmlPullParser can have either an InputStream or a Reader as the source of data. We simply read each XML tag in the RSS feed until we get to the end of the document. You can see in the code snippet below, that we are only interested in the XML tag if it is either title, description or link.

public List<RssFeedModel> parseFeed(InputStream inputStream) throws XmlPullParserException,
IOException {
String title = null;
String link = null;
String description = null;
boolean isItem = false;
List<RssFeedModel> items = new ArrayList<>();
try {
XmlPullParser xmlPullParser = Xml.newPullParser();
xmlPullParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
xmlPullParser.setInput(inputStream, null);
xmlPullParser.nextTag();
while (xmlPullParser.next() != XmlPullParser.END_DOCUMENT) {
int eventType = xmlPullParser.getEventType();
String name = xmlPullParser.getName();
if(name == null)
continue;
if(eventType == XmlPullParser.END_TAG) {
if(name.equalsIgnoreCase("item")) {
isItem = false;
}
continue;
}
if (eventType == XmlPullParser.START_TAG) {
if(name.equalsIgnoreCase("item")) {
isItem = true;
continue;
}
}
Log.d("MyXmlParser", "Parsing name ==> " + name);
String result = "";
if (xmlPullParser.next() == XmlPullParser.TEXT) {
result = xmlPullParser.getText();
xmlPullParser.nextTag();
}
if (name.equalsIgnoreCase("title")) {
title = result;
} else if (name.equalsIgnoreCase("link")) {
link = result;
} else if (name.equalsIgnoreCase("description")) {
description = result;
}
if (title != null && link != null && description != null) {
if(isItem) {
RssFeedModel item = new RssFeedModel(title, link, description);
items.add(item);
}
else {
mFeedTitle = title;
mFeedLink = link;
mFeedDescription = description;
}
title = null;
link = null;
description = null;
isItem = false;
}
}
return items;
} finally {
inputStream.close();
}
}

RssFeedModel is a simple helper class we created to hold title, description and link information for an RSS feed item.

public class RssFeedModel {
public String title;
public String link;
public String description;
public RssFeedModel(String title, String link, String description) {
this.title = title;
this.link = link;
this.description = description;
}
}

Displaying the feeds

At this point, we are ready to fetch, and parse RSS feeds. However, we still need to display the results in our rss reader RecyclerView. Recall that in the onPostExecute() method above, there is the line:

mRecyclerView.setAdapter(new RssFeedListAdapter(mFeedModelList));

Once again, if you haven’t used a RecyclerView before, check out our previous tutorial on Using RecyclerView. It is very easy and straightforward to use. To display each feed item, we create a layout file, called item_rss_feed.xml.

Building a simple RSS reader – full tutorial with code

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/titleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold" />
<TextView
android:id="@+id/descriptionText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/linkText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorAccent" />
</LinearLayout>

And finally, the RssFeedListAdapter.

public class RssFeedListAdapter
extends RecyclerView.Adapter<RssFeedListAdapter.FeedModelViewHolder> {
private List<RssFeedModel> mRssFeedModels;
public static class FeedModelViewHolder extends RecyclerView.ViewHolder {
private View rssFeedView;
public FeedModelViewHolder(View v) {
super(v);
rssFeedView = v;
}
}
public RssFeedListAdapter(List<RssFeedModel> rssFeedModels) {
mRssFeedModels = rssFeedModels;
}
@Override
public FeedModelViewHolder onCreateViewHolder(ViewGroup parent, int type) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_rss_feed, parent, false);
FeedModelViewHolder holder = new FeedModelViewHolder(v);
return holder;
}
@Override
public void onBindViewHolder(FeedModelViewHolder holder, int position) {
final RssFeedModel rssFeedModel = mRssFeedModels.get(position);
((TextView)holder.rssFeedView.findViewById(R.id.titleText)).setText(rssFeedModel.title);
((TextView)holder.rssFeedView.findViewById(R.id.descriptionText))
.setText(rssFeedModel.description);
((TextView)holder.rssFeedView.findViewById(R.id.linkText)).setText(rssFeedModel.link);
}
@Override
public int getItemCount() {
return mRssFeedModels.size();
}
}

Building a simple RSS reader – full tutorial with code

Wrap up

As always, the complete source is available on github. You can look into styling your item_rss_feed.xml, displaying more content than just the item title, description and link, and/or, for the adventurous, writing your own RSS news aggreagator with multiple feeds from multiple sources.

Happy coding.

Department of Transportation proposes new rules for phone calls during flights

New York Daily News

On Thursday, The Department of Transportation proposed a few new rules that would allow airlines to decide whether they will let passengers make voice calls during flights using the aircraft’s onboard Wi-Fi system.

However, the rules state that airlines and ticket agents would have to let the passengers know in advance that making voice calls during the flight is allowed and that, therefore, mid-air distractions can be expected.

Consumers deserve to have clear and accurate information about whether an airline permits voice calls before they purchase a ticket and board the aircraft. Today’s proposal will ensure that air travelers are not unwillingly exposed to voice calls, as many of them are troubled over the idea of passengers talking on cell phones in flight. — Anthony Foxx, U.S. Secretary of Transportation.

As of now, the final decision regarding the implementation of the above-mentioned rules has not been made. The Department of Transportation will first take the feedback it gets from airlines as well as passengers on this topic into consideration, which might take some time.

See also:

Google Flights will inform you when you can buy the cheapest ticket

October 17, 2016

So, if you have a strong opinion regarding the topic and want your voice to be heard, head over to the official website of the Department of Transportation by clicking the button below to post your comment.

Post your comment

Also feel free to express your opinion in the comments section below. We would love to hear what you think about the proposed rules.