1. Multiple camera apps + fingerprint

There are some gestures that can be used to launch some actions when the One Plus 2 is locked. In the settings menu you can enable and disable these gestures. One of these gestures is to open the camera as the following screenshot shows: the camera app opens when you draw an O on the screen.

When you have more than one app for the same action in Android, like the camera, and you have not selected a default app for that, a dialog is displayed . This dialog lets you decide which app you want to use. The following screenshot shows this scenario when I have to select one of the camera apps that I have installed.

When you use the O gesture on the One Plus 2 to launch the camera app, since there is no default app, the dialog to choose one is displayed. If you unlock the phone using your fingerprint, then right after that, the camera app selector closes and no camera app is launched. If you unlock your phone using other security mechanism then there is no issue.

You can watch this in the next video and notice how the selector appears and then disappears immediately.

2. Google Camera

The One Plus 2 has the One Plus camera app installed, but the Google Camera has some features, like the photo sphere, that I also like to have.
When I tried to take a panorama, it just does not work. It takes one photo, sometimes 2 or 3 photos, and then the app stops taking more. If you try to finish the panorama, it does nothing. When you try to discard the panorama, the app freezes and closes.
Here is the video:

One of the key factors to the adoption of wearables is their battery life.

We already use laptops, smartphones and tablets that we need to charge almost everyday. Having a wearable device like a smartwatch implies one more device to charge. If our smartphone has a low battery level, we can find a place to charge it while we do some other things. With a smartwatch we need to take it off. We can’t check the time while it is charging, at least not just by looking at our wrist.

Battery life is an important feature that we should consider when choosing a smartwatch, so I have measured the battery drain of the Apple Watch. In this post I want to show the results.

These are the specifications of the Apple Watch that I have used for the tests:

Battery drain

I analyzed the battery drain of the Apple Watch doing a very basic use of it.

This means that I checked the time once in a while and I read some notifications. Nothing more. I didn’t spend time exploring apps from the watch, I didn’t use the maps nor I monitored any type of exercise.
The results indicate that the battery life of the Apple Watch is around 50 hours: a little more than 2 days.
Therefore if you do more actions with the Apple Watch than just simply checking the time or reading notifications, the battery life will be less than 2 days, which means you need to charge it everyday.

The following chart shows the battery drain over time.

Power reserve

When the battery level of the Apple Watch is very low, around 10%, the power reserve mode is started automatically. You can also start this mode in any moment from the Power glance or from the power off menu.

While in the power reserve mode, you can only see the time on the screen along with an icon showing the red battery level icon. The watch doesn’t react to your finger touch and you need to press the physical side button to see the time.

When the Apple Watch is in power reserve, the battery drain is much lower. This can be observed in the next chart, where the power reserve mode was enabled during some hours.

More results

Charging time
It takes around 120 minutes to charge the Apple Watch completely, that is around 2 hours.

Boot time
It takes around 1 minute and 10 seconds to boot the Apple Watch.

In this post I want to show you the first look at Apple Watch. This post includes: pairing the watch with your iPhone, the charger and what happens when the watch is disconnected from the paired iPhone.

My experience is that the Apple Watch is a cool gadget to wear, but I ended up using the phone for everything and the watch only to see the time. The Apple Watch is not really good to check the time, since the screen turns on automatically when you do the movement with your wrist. There are sometimes that I don’t do this movement, or that the watch does not detect it. In these cases, you have to touch the screen with your finger. Anyway the wrist movement detection works really good.

These are the specifications of the Apple Watch that I have used for this post:

The following image shows the box containing the Apple Watch. Two watch bands with different sizes are included.

Pairing the Apple Watch

You need your Apple Watch (of course) and the companion Apple Watch app on your iPhone.The companion Apple Watch app is available since iOS version 8.2. First make sure that you have updated your device to iOS 8.2 or later. You should see the following Apple Watch icon on your device.

Once you turn on your Apple Watch, it will ask you to set it up and pair it with your iPhone.
Open the Apple Watch app on your iPhone and follow the steps of the setup assistant. Finally press the “Start Pairing” button on your watch.

Both the watch and the phone display a screen indicating the syncing process.

When the syncing is finished, you’re ready to go!

Charging the Apple Watch

The charger is a magnetic charging cable. You only need to place your watch on the charger.

When the battery level of the Apple Watch is very low, around 10%, the power reserve mode is started automatically. You can also start this mode in any moment from the Power glance or from the power off menu.
While in the power reserve mode, you can only see the time on the screen along with an icon showing the red battery level icon. The watch doesn’t react to your finger touch and you need to press the physical side button to see the time.
The following left image shows the watch with low power level. The right image shows the watch while charging.

Disconnected from your iPhone

The Apple Watch needs your iPhone to support most of its features. If the watch can’t communicate with your phone, a red icon is displayed on the top part of the screen as shown in the following image.

When the phone is out of range, some apps won’t work on the watch.
As shown in the next left image, a red message warns the user that the data was last updated some days ago. The red icon indicating that the phone is not in range is displayed on the top right corner of the watch screen. The right image shows an application with no data at all.

In this post I want to show you how we can create the simplest iOS app that monitors and ranges devices that follow the iBeacon protocol. An iBeacon device is a BLE (Bluetooth Low Energy) device that transmits its identification information: UUID, major and minor.
You can learn more about iBeacon in this previous post here.

Project setup

Create a new empty project in XCode. You can select the Single View Application template.

Enable the permissions needed to use the Core Location services. To do this, add the following two properties in the .plist file of your app:

NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription.

Here is an example of these two properties:

<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is needed to monitor Beacons in range</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is needed to monitor Beacons in range</string>

My Location Manager

Create the class that will manage all the beacon events: MyLocationManager.

Import the CoreLocation library in the .h file of your new class:

#import <CoreLocation/CoreLocation.h>

The MyLocationManager class is going to implement the CLLocationManagerDelegate protocol to receive the beacon events:

@interface MyLocationManager : NSObject <CLLocationManagerDelegate>

The MyLocationManager class also needs two methods so the app can start/stop monitoring iBeacons. Add these methods to the interface:

- (void)startMonitoringUUID:(NSString *)uuid;
- (void)stop;

Monitoring iBeacons

Open the implementation .m file of our MyLocationManager class and add a private property to keep an instance of the iOS system CLLocationManager class.

Line 3. Create an object of the CLLocationManager class.
Line 4. Set our MyLocationManager object as its delegate.
Line 7-8. Request permission.
Line 10-12. Create a region with the UUID received as parameter.
Line 14. Start monitoring for the recently created region.

Implement the delegate method to receive the iBeacon events. For this small sample app, iBeacon events are just printed to the app log:

Ranging iBeacons

Add the code to start ranging. A good approach is to start ranging once it has been detected that the user is inside a region. This code is added in the locationManager:didDetermineState:forRegion method:

The iBeacon standard is an extension of iOS Location Services. An iBeacon device is a BLE (Bluetooth Low Energy) device that transmits its identification information: UUID, major and minor. This information is hierarchical and the UUID is the beacon’s principal identifier.
The iBeacon functionality provided by iOS allows two types of actions:

Region Monitoring. Notifies when the user has entered the specified region.

Beacon Ranging. Determines the estimated proximity to the beacons in range: Immediate, Near, Far or Unknown.

A Region in iBeacon terms is a network of iBeacons defined by a shared identifier. A region can be specified by its UUID, major and minor. Major and minor identifiers are optional for a region, but the UUID is necessary.

iOS limits to 20 the number of regions that may be simultaneously monitored by a single app.

For example, if only the UUID is specified for a region, all the iBeacons with that UUID will be considered part of that region.

If we specify the UUID and also a major value for the region, then only the iBeacons with that UUID and major are considered as part of that region.

Once a region has been detected, the details of the iBeacons in range inside that region are obtained by ranging, not by monitoring.

Background detection

While the app is running in the foreground it can range to determine the signal strength between the iBeacons and the device. This ranging process is not allowed while the app is not running in the foreground. Only monitoring is allowed while the app is in the background/not running.
Region monitoring is capable of waking the app up from running in the background/not running when the app enters or exits the region. These are the only triggers that will wake the app from running the background/not running: entering or exiting a region. Once the app is awoken it can run for ~10 seconds if closed completely and ~2 minutes if it is running in the background.

Core Location Framework

iBeacon APIs are available in the Core Location Framework. The central point of this framework is the CLLocationManager class. An instance of this class is necessary to start/stop the location services, to configure them, and to receive the related events.
The CLLocationManager reference can be found here.

An Adapter is an object that provides data to certain components like a ListView object or a Spinner object. There are distinct classes that implement the Adapter class, such as ArrayAdapter, which loads an array of objects. We can create a custom adapter that extends the ArrayAdapter class to create custom items.
Let’s say that we want to display Event objects in a ListView. This is our custom adapter:

This refresh method clears all the data from the list and updates it with new data. Alternatively you can create different methods to add or remove items. In any case, the most important part is to invoke the notifyDataSetChanged method. The notifyDataSetChanged method notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.

Finally, from the activity or fragment that contains the list, invoke the previous method with the new data:

mAdapter.refreshEvents(newListOfEvents);

Consider the case in which the refresh method is not called from the UI thread. For example, if the data is updated after a server request:

A navigation drawer is a common structure for the top-level of our Android app. A drawer provides a safe start point of return with which users can easily understand the application structure.

Using Android Studio, we can create a project from the template of an activity with a navigation drawer:

A navigation drawer can be opened by a button placed in the top action bar or by swipe gestures. The default action bar for the drawer contains the icon button that opens/closes it, which is known as the toggle button. The action bar, the title and the button have their own default colors.

To change the default action bar with our custom colors, we need to change the styles xml file of our app, which initially only contains the base app theme:

When we have a UITableView, sometimes we want to add some actions when the user swipes over a row of the table. We can capture swipes to the left, right, down or up directions.
To capture both left and right swipe gestures, add the following code to your UITableViewController in the viewDidLoad method.

The method locationInView returns the location of the gesture, represented as a point in the local coordinate system of the view. Using the indexPathForRowAtPoint method of the UITableView object, we can obtain the row of the gesture.

We could use also the same action method to handle all the swipe gestures. Change the action methods from handleSwipeLeft and handleSwipeRight to handleSwipe, and add the following method instead.

Finally, we have to add in the Info.plist file of our app the values for the keys NSLocationWhenInUseUsageDescription or/and NSLocationAlwaysUsageDescription. These values contain the messages that will be displayed to the user when requesting the authorization.

Android Studio Essentials is my third book that has been recently published by Packt Publishing here. You can get it also from Amazon here. This book is an update of my previous book “Android Studio Application Development”.

Android Studio is an IDE that is based on the JetBrains IntelliJ IDEA. It gives developers a unique platform to develop and debug Android apps using various developer tools. It has a wide array of features such as live layout facility, Gradle build support, and template-based wizards, which makes it a preferred choice for developers.

Starting off with the basic installation and configuration of Android Studio, this book aids you in building a new project by helping you to create a custom launcher icon and guiding you to choose your activity. You then gain an insight on the additional tools provided in Android Studio, namely the Software Development Kit (SDK) Manager, Android Virtual Device (AVD) Manager, and Javadoc.

Finally, it helps you to familiarize yourself with the Help section in Android Studio that enables you to search for the help you might require in different scenarios.