LightBlog

mercredi 10 août 2016

How to create more powerful Android notifications

notification part 2 image-16x9-720p

A  typical notification provides some useful information to the user, who can then either dismiss it or act on it – usually by tapping the notification to launch the app associated with this notification. For example if you see a 'You have a new message' notification, then chances are that tapping it will launch an application where you can view the message you've just received.

Most of the time, this is all you need to worry about when you're creating notifications – but what if you have something more specific in mind, such as a custom layout, or enhanced notifications that deliver extra functionality? Or maybe you've just finished testing your app and feel like its notifications are an area where you could improve the user experience.

Following my first tutorial on how to create a simple Android notification, in this article I'm going to look at ways to create more powerful notifications including custom layouts, expandable notifications, and other bits of additional functionality.

Let's start with some of the new notification features that we're all currently looking forward to in the up-and-coming release of Android Nougat.

Direct Reply Notifications

Android 7.0 introduces 'direct reply,' a new notification interaction that's perfect for messaging apps  – or any applications that have some kind of messaging functionality.

Direct reply allows the user to reply directly from a notification's UI – they don't even have to navigate away from whatever they're currently doing! The user just has to tap the notification's action button and then they can type their response into the text input field that appears in the notification's UI.

Direct reply notifications as they appear in the Android N Developer Preview.

Direct reply notifications as they appear in the Android N Developer Preview.

To add direct reply functionality to a notification, you need to create a RemoteInput instance that's capable of receiving input from the user and passing it to your app. You also need to create an identification key that you'll use to retrieve the user's input (in this example, I'm using key_quick_reply).

  RemoteInput remoteInput = new RemoteInput.Builder(KEY_QUICK_REPLY)  .setLabel(replyLabel)  .build();  

Use the addRemoteInput method to attach your RemoteInput instance to the reply action:

  NotificationCompat.Action action =  new NotificationCompat.Action.Builder(R.drawable.reply, replyLabel, pendingIntent)  .addRemoteInput(remoteInput)  .setAllowGeneratedReplies(true)  

You can then build and issue the notification, as normal – just make sure you add the remote action to the notification builder, using AddAction.

To retrieve the user's input, call the RemoteInput.getResultsFromIntent() method and use the identification key you created earlier:

  Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);    if (remoteInput != null) {  return remoteInput.getCharSequence(KEY_QUICK_REPLY).toString();  }  

After you've processed the user's input, don't forget to update your notification to let the user know that their response has been heard loud and clear – you don't want to leave the user wondering whether your notification has even registered their input!

Bundled Notifications

When your application issues multiple related notifications, it's best practice to generate a single notification and then update that notification's UI with information about each subsequent event. Typically, this takes the form of a headcount – so a "New message received" notification becomes "You've received 2 new messages," "You've received 3 new messages," and so on.

While this prevents your notifications from cluttering up the user's device, a headcount alone probably isn't going to give the user all the information they need. So you have 3 new messages – but from who? What are the subject lines? And how old are these messages, anyway? If the user wants answers to any of these questions, they're going to have to launch your app.

Android 7.0 aims to improve this part of the user experience by bringing the 'notification grouping' feature, that you may have encountered in Android Wear, to Android smartphones and tablets.

bundled_notifications-16x9-720p

This feature groups related notifications under a single header. If it seems like your app might generate multiple, related notifications within a short space of time, then you may want to create notifications that the system can bundle together, if the opportunity arises.

Not only does this help you avoid clogging up the user's notification bar, but it gives the user more flexibility in how they interact with your notifications. The user can either act on the entire bundle simultaneously, or they can drag to "unfurl" the bundle into its individual components. At this point, the user can see more information about each notification event, and can also interact with each event individually.

If you're going to use bundled notifications in your app, then the first step is creating a parent "summary" notification. Bear in mind that the summary notification may be the only notification the user sees if they don't unfurl the summary notification, or if they're running anything earlier than Android 7.0.

You create a summary using setGroupSummary. At this point you should also assign it a group ID, as this is the key to letting the Android system know which notifications belong to this particular group.

  NotificationCompat.Builder notificationOne = new NotificationCompat.Builder(context)  ...  ...  .setGroupSummary(true)  .setGroup(GROUP_KEY_MESSAGES)  

Then, whenever you create a notification that belongs to this group, you can assign it the same ID, for example:

  NotificationCompat.Builder notificationTwo = new NotificationCompat.Builder(context)  .setContentTitle("New SMS from " + sender1)  .setContentText(subject1)  .setSmallIcon(R.drawable.new_message)  .setGroup(GROUP_KEY_MESSAGES)  .build();  

Custom View Notifications

If you have a specific creative vision in mind, or you want to use components that aren't supported by the Notifications API, then you may want to create a custom notification layout.

Just be careful not to get carried away! While notifications that subtly tweak the standard layout can enhance the overall user experience, your custom layouts should always feel like a seamless part of the overall Android experience – particularly in this post-Material Design world where Android is all about providing a more cohesive user experience.

If you present the user with a custom notification that's not what they were expecting at all, then interacting with your notification can suddenly feel like an effort, rather than something that comes naturally to them. Not exactly the frictionless user experience you should be aiming to deliver!

If you do decide to use custom notifications, then start by creating the layout resource file that you want to use in your notifications.

build_layout-16x9

Then, you'll need to create a Notifications.Builder object and attach all the properties you want to use in your notification:

  Notification.Builder builder= new Notification.Builder(getApplicationContext());  .setSmallIcon(R.drawable.notification_icon);  

Create an instance of the Remoteviews class and pass it your application's package name, plus the name of your layout resource file:

  RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.custom_notification);  

Set whatever data and resources you want to use in your custom notification:

  remoteViews.setImageViewResource(R.id.image_icon, iconResource);  remoteViews.setTextViewText(R.id.text_title, title);  

Use the setContent() method to attach all the views from your notification's layout file:

  builder.setContent(remoteViews);  

Finally, build and issue your notification:

  Notification notification = builder.build();  NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);  notificationManager.notify(NOTIFICATION_ID , notification);  

Expanded Notifications

Android 4.1 introduced a new visual style for notifications, known as big view. This is an expanded view that appears when the user drags a notification open.

expanded_notification-16x9-720p

If you do decide to use expanded notifications, then just be aware that a notification's 'big view' only appears when the notification is expanded. There's no guarantee that the user will ever expand your notification (and expanded notifications aren't even supported on devices running Ice Cream Sandwich or earlier) so your notification's normal view needs to deliver all the information the user needs, in order to understand what they're being notified about.

When you're building notifications that contain both a normal view and a big view, it's generally a good idea to start by building the notification's normal view, as this is the first (and possibly only) version of the notification the user will see. Once you've perfected this part of your notification, you can move onto adding all the extra information you want to display in the all-singing, all-dancing expanded version.

Android provides three expanded layout templates that you can use in your projects: text, inbox, and image:

Big text style

This template displays additional text when the notification is expanded. This is handy if you're creating text-heavy notifications, or notifications where the text is the main focus, for example you may want to use this template when you're notifying the user about incoming SMS, instant messages or emails.

To create a big text style notification, use the following:

  Notification bigTextStyleNotification = new NotificationCompat.Builder(this)  .setContentTitle(getString(R.string.notification))  .setStyle(new NotificationCompat.BigTextStyle()  .bigText("This text replaces the notification's default text"))  ...  // Add any other formatting options you want to use for this notification.//  ...  ...  .build();  

Big picture style

This template includes a large image area, which is ideal when images are the main focus of your notification. For example, if you're developing a chat app then users may appreciate a clear profile picture of the person who's messaging them.

To create an expandable notification that uses the big picture style, add the following to your project:

  Notification bigPictureStyleNotification = new NotificationCompat.Builder(this)  .setStyle(new Notification.BigPictureStyle()  .bigPicture(aBigImage))  ...  ...    //More formatting information//    .build();  

Inbox style

This style allows you to generate notifications that contain a preview of up to 5 strings, where each string appears on a new line:

  Notification inboxStyleNotification = new NotificationCompat.Builder(this)  .setContentTitle("You've received some new messages")  .setContentText(subject)  ...  ...  //More formatting information about this notification//  .addLine("First Message")  .addLine("Second Message")  .addLine("Third Message")  .setSummaryText("+2 more"))  .build();  

Wrap-up

Now that you know how to go beyond the simple notification and use advanced features like Direct Reply, please let me about how you use notifications in your app. Do you use any other techniques when you're creating Android notifications? What else could Google add to Android's notification system?



from Android Authority http://ift.tt/2b63Fd6
via IFTTT

Deal: Nexus 5X for $224.99 on eBay (save 36%)

Nexus 5X ebay deal

There's a good deal going for the Nexus 5X on eBay right now. The offer saves $125 (36 percent) off the retail price, which sees the phone selling for just $224.99. You will have to hurry though, as stock is limited.

The Nexus 5X's launch last year may have been overshadowed by its bigger brother, the Nexus 6P. However, the phone still offers up some pretty nice mid-range specifications and the same excellent camera as it's sibling. I'll leave a quick breakdown of the specifications below.

  • 5.2-inch LCD display with 1920 x 1080 resolution
  • 1.8GHz hexa-core Snapdragon 808 processor
  • 2GB RAM, 16GB storage
  • 12.3 megapixel rear camera with laser autofocus
  • 5 megapixel front camera
  • 2,700mAh battery
  • USB Type-C port and fingerprint scanner
  • Honor 5X vs Nexus 5X vs OneP...
  • Nexus 5X Second Opinion
  • Nexus 5X Review
  • Nexus 6P vs Nexus 5X

The Nexus 5X is available in your choice of Carbon, Quartz, or Ice in this listing. Hit the button below to view the deal before stock runs out.

Buy now from eBay!


from Android Authority http://ift.tt/2bfCtKK
via IFTTT

90,000 units of the Xiaomi Redmi 3S Prime sold out in just 8 minutes in India

xiaomi-redmi-3s-16x9-720p
If you managed to order the Redmi 3S Prime at the flash sale on mi.com and Flipkart yesterday, then you'll be among the 90,000 lucky buyers to get your hands on the device. Xiaomi India head, Manu Jain has revealed that 90,000 units of the Redmi 3S Prime were sold out within just eight minutes of the smartphone going on sale online.

After being unveiled alongside the Redmi 3S at a launch event in Delhi last week, only the Redmi 3S Prime went on sale at Flipkart and mi.com yesterday at 12 PM local time. Once again, Xiaomi's impressive specs and aggressive pricing for the Redmi 3S Prime seems to have worked in its favor. When you consider that you are getting a smartphone with a 5-inch HD display, 3GB RAM, a fingerprint sensor, and a massive 4,100 mAh battery for just Rs 8,999 (~$135), the Redmi 3S Prime is certainly an attractive deal, especially in a budget-friendly smartphone market.

Not surprisingly then, the purchase of 90,000 units of the Redmi 3S Prime was "the highest volume ever" for a first sale held by Xiaomi, and also the most successful open sale for Flipkart. With its entire Redmi 3S Prime stock selling out in just eight minutes, Xiaomi has once again proved that it rules the sub-Rs10,000 Indian smartphone market.

Xiaomi Redmi 3S launch

In case you weren't able to pick up Xiaomi's ultra-affordable smartphone yesterday, don't be disappointed. The company has announced that the Redmi 3S Prime will once again go on sale, this time along with the Redmi 3S, on August 17 at 12 noon on Mi.com and Flipkart. The Redmi 3S is priced even more competitively at Rs 6,999 (~$105) and comes with 2GB RAM and 16GB storage, and without a fingerprint scanner.

Going by the demand for Xiaomi's ultra-affordable smartphones among Indian consumers, the company will hopefully make more units of both the devices available for sale this time.

Let us know in the comments below if you plan to buy the Redmi 3S or the Redmi 3S Prime at the next flash in coming up on August 17!



from Android Authority http://ift.tt/2bfCpL3
via IFTTT

Samsung Galaxy On7 (2016) and On5 (2016) spotted at TENAA

Galaxy On7 2016

A new generation of Samsung Galaxy On handsets could be on their way to China soon, as Galaxy On5 (2016) and Galaxy On7 (2016) models have just been spotted passing through TENAA. Thanks to the TENAA listings, we have a pretty good idea about the baseline specifications of these two phones now as well. Interestingly, these handsets look to offer a substantial boost to the specifications of the On5 Pro and On7 Pro handsets that were announced for the Indian market back in July.

The Galaxy On5 (2016) will again be a 5-inch model, boasting a LCD panel with a 720p resolution. The phone will be powered by a 1.5GHz octa-core CPU, quite likely to be the Snapdragon 617, which will be accompanied by 3GB of RAM and 32GB of internal storage with a microSD card slot. The On5 also looks to be arriving with a 13 megapixel rear camera, 8 megapixel front camera, a 2,600mAh battery, and a fingerprint scanner.

samsung logo mwc 2015 4See also: Samsung Galaxy On5 (2016) receives FCC certification7

The Galaxy On7 (2016) is the larger and slightly more powerful of the two. It's display is a 5.5-inch LCD panel with an improved 1080p resolution. The phone is powered by a 2.0GHz octo-core CPU, possibly the newer Snapdragon 625, along with 3GB of RAM and 32GB of internal memory.

In addition, the Galaxy On7 (2016) features the same 13 megapixel rear and 8 megapixel front specifications as the new On5. There's also a fingerprint scanner, Android 6.0.1, and a slightly larger 3,300mAh battery installed. That's some rather decent mid-range hardware overall, providing that the price is right.

What do you think about the two Galaxy On (2016) models?



from Android Authority http://ift.tt/2beChZ2
via IFTTT

Android continues to dominate as iOS returns to growth in U.S. and Europe

Galaxy-S7-Edge-vs-iPhone-6s-plus-3of18

Android's global growth has continued relatively unchecked in recent quarters. While Apple is dealing with back-to-back quarterly declines in iPhone sales amidst investor concerns, the path ahead is looking pretty rosy for Android. All this despite worldwide smartphone trends that indicate a plateauing mobile market.

Samsung Galaxy S7 and S7 Edge Tips and tricks-10See also: The Galaxy S7 Edge is the world's top-selling Android phone in 201644

But the most recent figures from Kantar Worldpanel show iOS scraping out a minimal increase in market share in both the U.S. and Europe. While any upswing in market share is better than a downturn, Apple's gains were very moderate.

In the U.S., iOS posted a 1.3% increase from this time last year and only increased by 0.7% overall in the EU5 (Germany France, Great Britain, Italy and Spain). As Kantar notes:

Combined sales of the iPhone 6s/6s Plus totaled 15.1%, making this the top selling device in the quarter, while the Samsung Galaxy S7/S7 edge accounted for 14.1% of smartphone sales. The iPhone SE became the third best-selling phone at 5.1%.

Galaxy-S7-Edge-vs-iPhone-6s-plus-10of18

Meanwhile in China, Apple continued its slow demise, dropping 1.8% of its market share and slipping to third place behind both Huawei in the top spot and Xiaomi in second position. IOS also saw a significant loss in Japan, where it dropped 4.2% from this time last year.

In China, Apple slipped to third place behind both Huawei and Xiaomi.

Android, on the other hand, rose significantly in almost all markets, posting increases across the board: EU5 (+5.5%); China (+2.1%); Japan (+6.6%); and Australia (+4%). In the U.S. however, Android saw a minor decrease in market share, dropping 0.6% but still retaining 65.5% of the total U.S. smartphone market. In the EU5 that market share stands at an impressive 76.8%.

However, Kantar predicts a weak third quarter for Apple, because "anticipation for the newest iPhone, usually released in late September every year, typically means a weaker summer period for iOS". With the Galaxy Note 7 release already behind us, we can only expect to see more gains made for Android in the current quarter.

Did you expect Apple to return to growth? Do you think it will drop again this quarter?



from Android Authority http://ift.tt/2beCz29
via IFTTT

Xiaomi Redmi 4 and Mi Note 2 specs and release dates rumored

Xiaomi Mi 4S-12

According to a tip posted to Weibo, Xiaomi looks to have two more smartphones scheduled for release this year – the Mi Note 2 and Redmi 4. In typical Xiaomi fashion, both handsets are said to offer very compelling specifications at tough to beat price points.

Starting with the Mi Note 2, the phone is shaping up to be excellent value for those looking for a large high-end flagship. According to the report, the Mi Note 2 replaces the original Note's Snapdragon 801 for the new Snapdragon 821, offering a big performance boost. There are some conflicting views about the display, with some reports suggesting AMOLED while others point to a 5.7-inch LCD panel with a 1080p resolution. Other specs are said to include a metal body, fingerprint scanner on the front, a 3,600mAh battery, and either 64GB or 128GB of storage perhaps paired with either 4GB or 6GB of RAM, depending on the storage option.

metal-redmi-4

Another alleged shot of the Redmi 4's metal body

The Xiaomi Mi Note 2 is stated to cost 2499 ($375) and 2799 yuan ($405), depending on the memory configuration. The phone will apparently be launched on September 5th.

The successor to Xiaomi's range of Redmi 3 handsets will appear a little earlier, as it is rumored to launch on August 25th. The Redmi 4 is a more mid-range smartphone, expected to arrive with a 5-inch 1080p display, Snapdragon 625 processor, 3GB of RAM, 32GB of internal storage, and a 4,100mAh battery. The phone is also said to come with a metal unibody, a rumor that we've heard before.

Again, we're looking at a decent boost in processing power with this new generation model. Xiaomi's Redmi 4 will be priced at just 699 yuan ($105) too, potentially making it an incredibly tough handset to beat at this price.

xiaomi-logoSee also: Leaked images show off metal-clad Xiaomi Redmi 411


from Android Authority http://ift.tt/2aYMjNY
via IFTTT

Flipkart Freedom Sale – best deals and offers

flipkart-freedom-sale
As Amazon's Great Indian Sale enters its last day, rival Flipkart kicks off their Freedom Sale today, bringing attractive discounts and exchange offers on smartphones, apart from a wide range of other products. With so many sales going on, keeping track of all those deals and offers across multiple e-commerce platforms can be a bit tricky. We are here to help you out with this roundup of some of the best deals offered by Flipkart.

Start shopping now

If you've always wanted to pick up one of the popular smartphones in the sub-Rs 10,000 (~$150) segment, the 2 GB RAM variant of the Vibe K5 Plus is now available with a Rs 1,000 (~$15) discount. An exchange bonus of as much as Rs 6,500 (~$98) can get you the Vibe K5 Plus for just Rs 999 (~$15).

Xiaomi Mi 5-12

Also on offer is Xiaomi's flagship Mi 5 smartphone, that launched in India earlier this year at a price of Rs 24,999 (~$375). You can now grab the black or white variants of the Mi 5 for a slightly discounted Rs 22,999 (~$345). Add on an exchange bonus of up to Rs 15,000 (~$225), and the Mi 5 can be yours for just Rs 7,999 (~$120).

Motorola fans also have something to be excited about, with the highest discounts on offer being for their range of smartphones. The 16 GB variant of the Moto X Play 16GB variant is selling for Rs 3,500 (~$53) less at Rs 13,999 (~$210). You get an exchange bonus of up to Rs 13,000 (~$195) on the Moto X Play as well, in which case, the handset could cost you just Rs 999 (~$15).

Moto X Style Hands On-31

Next up is the Moto X Style, available with a massive discount of Rs 6,000 (~$89). The device is now priced at Rs 22,999 (~$345), and with exchange offers up to Rs 15,000 (~$225), this handset could be yours for as low as Rs 7,999 (~$120). The Moto Turbo gets the highest discount of Rs 10,000 (~$150), to bring its price down to Rs 21,999 (~$330). The same exchange bonus is available here as well, which means that you could end up paying only Rs 6,999 (~$105) for the handset.

It's not just raining discounts on Motorola smartphones alone, but also on their smartwatches. The Moto 360 Sport, that was launched earlier this year for Rs 19,999 (~$300) is available for Rs 5,000 (~$75) less. All the other Moto 360 (2nd Gen) smartwatches are also available at a discount of Rs 3,000 (~$45).

moto-360-2nd-gen-review-aa-4-of-27

You can now buy the 42mm variant for men with black leather for Rs 16,999 (~$255), and the 46mm variant for men with black metal for Rs 20,999 (~$315), while the 42mm blush leather and silver metal variants for women are selling for Rs 16,999 (~$255) and Rs 19,999 (~$300), respectively.

If storage is a concern, and if you are looking for a device that will certainly stand out from the crowd, then you should consider the Nextbit Robin.  The device was launched in India priced at Rs 19,999 (~$300), but for the next two days, you can get it for just Rs 14,999 (~$225). Also available are the LeEco Superphones such as the Le 2, Le Max2, and Le 1s Eco, but while there are no significant discounts here, you can take advantage of a "no cost EMI" offer.

nextbit robin review aa (11 of 20)

Apart from these discounts, you can also enjoy an additional 10% off when using a HDFC credit card, and 15% off when using a card from Digibank by DBS, and "Crazy Deals" will be available between 6 PM and 8 PM. The Flipkart Freedom Sale will continue till August 12, so if you're looking to pick up any new devices, now is the time to do so.

Start shopping now

Happy shopping!

Let us know in the comments below if you found some great deals on the Flipkart Freedom Sale!



from Android Authority http://ift.tt/2aYKjVZ
via IFTTT