LightBlog

lundi 17 octobre 2016

Deal: Save up to 25% on the Sony Xperia X range today only

amazon xperia x sale 5

If you're in the mood for some Sony Xperia X action, Amazon has discounted a selection of unlocked Xperia X, Xperia XA and Xperia X Performance models. Each device is available in four color variants – White, Black, Rose Gold and Lime Gold – with free shipping for a limited time only. Here's the full list:

The Sony Xperia X Compact isn't mentioned in Amazon's deals section but it remains at a 10-percent reduction since soon after it launched. If you're interested, you can find that deal here.
  • Sony Xperia X Compact Review...
  • Sony Xperia X Performance Ca...
  • Sony Xperia X Performance re...
  • Sony Xperia X review
The above offers end in less than 17 hours, so if you're interested you'll have to act fast. Which version would you prefer? Let us know in the comments.


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

ZTE Axon 7 Mini US pre-orders begin for $300

ZTE Axon 7 mini 23

US pre-orders for the ZTE Axon 7 Mini have officially begun. The unlocked phone is available from several retailers for the price of $299.98. While an official release date for the phone in the US has not yet been announced, the device was previously launched in some European markets for €299.

ZTE says that the Axon 7 Mini will come in Ion Gold as an exclusive to Best Buy stores for the first 60 days.  The Platinum Gray color version is available from several retailers, including Amazon, B&H, Best Buy, NewEgg and ZTE's own online store.

zte-axon-7-miniSee also: ZTE Axon 7 mini hands-on10

The ZTE Axon 7 Mini is being marketed, unsurprisingly, as a smaller 5.2-inch version of the larger 5.5-inch Axon 7. The Mini has an 1920×1080 AMOLED display, and inside there's an Qualcomm Snapdragon 617 processor, along with 3GB of RAM and 32GB of internal storage. It also includes a microSD card slot to add more storage to the phone up to 128GB.

The Axon 7 Mini has a 16 megapixel rear camera, an 8MP front-facing camera, a non-removable 2705mAh battery and runs Android 6.0.1 Marshmallow out of the box. The all-metal body also features dual front facing speakers.

At the moment, it looks like the pre-order links for the third-party retailers are still in the process of rolling out but it is currently live on ZTE's online store. Are you planning to jump in and get this latest unlocked smartphone from ZTE?

Get it at ZTE


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

LG G5 could get Android 7.0 Nougat update in mid-November

LG G5-29

An Australian wireless carrier has posted word that the LG G5 could start getting its over-the-air update to Android 7.0 Nougat sometime in mid-November.

The report comes from the newly refreshed Android Software Updates support page from Optus. The listing for the LG G5 shows that Android 7.0 is currently in testing for the smartphone and it is "expected" to be released for those customers in mid-November. LG did offer a small number of LG G5 owners in South Korea a way to get the Android 7.0 update as part of a preview program earlier this year.

lgg5thumbSee also: LG G5 Review!128

It's important to keep in mind that system update schedules from wireless carriers are not always 100 percent reliable and they can, and usually do, change. However, LG has been among the first smartphone companies to roll out Android OS updates for their older devices in the past. This makes this new schedule from Optus more believable. Unlocked LG G5 models may get the update a little earlier, and of course other carriers will likely roll out the Nougat upgrade on their own schedules after they test the OS out.

Android N logo AASee also: Android 7.0 Nougat update arrives: when will you get it?243

The LG G5 launched earlier this year and was one of the first mainstream smartphones to embrace the modular trend. The company launched "Friends" accessories. including camera and speaker modules, that connected directly to the phone. Even with these "Friends", the LG G5 was something of a sales disappointment for the company. LG hopes to bounce back with the launch its latest smartphone, the LG 20. The smartphone, which comes with Android 7.0 Nougat out of the box. will officially launch on October 28 in the US.



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

OnePlus announces Diwali Dash promotion in India

oneplus-diwali

OnePlus has launched their Diwali Dash festival in India where customers can win prizes for just ₹1. The company had last week announced their exclusive online store in the country.

The Diwali Dash Sale will be held between October 24 to 26, each day at 12PM, 4PM, and 8PM IST. The (very) long participation process involves account registration, mobile number verification, registering shipment address, as well as sharing the event on one of the social media platforms in order to win an 'entrance ticket'.

Once the customer has an entrance ticket, he'd be eligible to purchase a mystery product for just ₹1 (less than two cents, really). The contents of Mystery Boxes depend on event participation levels. Each session would have a range of Mystery Boxes that will be released through a lucky draw. The contents of the Mystery Box will be revealed once the payment is done, else they'll expire after three hours.

Also, OnePlus users can register themselves using their OnePlus phone's IMEI number to win an assured coupon worth ₹250. There's another contest with goodie bags up for grabs.

It's festive season in India, and OnePlus wants to indulge in the same, but the promotional contests could be simpler and more fun, really. Head to the Diwali Dash festival page on the new OnePlus store to check out the details and participate.



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

How to build a simple calculator app – full tutorial with code

simple_calc_featured_image

Continuing the Android Authority tradition of building simple apps (see how to build an image gallery app and how to create an SMS app), we are going to build a simple but functional calculator app. If you're new to programming and have never built an app before, you should check out our previous tutorial on writing your first Android app. This tutorial assumes that you have at least, some basic experience writing Android apps.

Much like developing any non-trivial program, there is more than one way to do it, and if you get ten different programmers, you might get ten different ways of writing a calculator (unless they all happen to be Android Authority readers *wink*). The complete source for the calculator app written below is available on github for use, reuse and modification as much as you like.

Creating the project

The first thing to do is create a new project by either clicking on "Start a new Android Studio project", or 'File -> New -> New Project'.

Simple Calculator - new project

For this calculator tutorial, we selected the EmptyActivity option on the "Add an Activity to Mobile" screen, and left the Activity name as the default MainActivity. At this point, your layout hierarchy should look like the image below. You have a MainActivity within your project package, and an activity_main.xml file in the layout directory.

Simple Calculator - heirarchy

Enable data binding in your project

For our sample calculator, we will setup our project to use data binding. Using data binding in this app simply helps us refer to our widgets (Buttons, EditText and TextView) directly, rather than finding them with findViewById() methods. To enable data binding, you must add the following line to your app build.gradle file.

  android {      ...      dataBinding.enabled = true      ...  

Simple Calculator - data binding

Designing the Calculator layout

To enable data binding in our activity_main.xml file requires one last change. Wrap the generated root tag (in our case it was a RelativeLayout) within a layout tag, making the layout tag the new root tag.

  <?xml version="1.0" encoding="utf-8"?>  <layout>      <RelativeLayout>      ...      </RelativeLayout>  </layout>  

The layout tag is what alerts the build system that this layout file intends to use data binding. The build system then generates a Binding class automatically for this layout file. Since the target xml file is named activity_main.xml, the build system will generate a class called ActivityMainBinding, which you can reference in your app like any other Java class. The class name is generated from the layout file name by capitalizing the first letter of each word after an underscore, removing all underscores, and adding 'Binding' to the name.

At this point, switch to your MainActivity.java file. Create a private ActivityMainBinding instance within your class, and in the onCreate() method, delete the setContentView() line and replace with the DataBindingUtil.setContentView() line in the code snippet below.

  public class MainActivity extends AppCompatActivity {      private ActivityMainBinding binding;        @Override      protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          binding = DataBindingUtil.setContentView(this, R.layout.activity_main);      }  }  

Understanding the layout widgets

There are four main items in our calculator app. These are:

  1. RelativeLayout – this item governs how the other items are laid out, or displayed on the screen. The RelativeLayout is used to position child elements in relation to each other, or to itself.
  2. TextView – this item is used to display text. Users are not expected to interact with this item. The result of computations are displayed using a TextView.
  3. EditText – this is a kind of TextView that users can edit, and change the text. However, since the calculator allows only a fixed set of inputs, we set the edit text to be non-editable. When the user clicks on numbers, we display the numbers in the EditText.
  4. Button – this item allows interaction by the user, and ideally, should respond to clicks by the user. We use buttons for the numbers, and operators in the calculator.

Building the Calculator layout

Simple Calculator - main layout

The calculator layout is a bit long. This is due to the fact that we have to explicitly define, and meticulously position, each of the buttons in the calculator. The snippet below is a condensed version of the activity_main layout file

  <layout>      <RelativeLayout xmlns:android="http://ift.tt/nIICcg"          xmlns:tools="http://ift.tt/LrGmb4"          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.samplecalculator.MainActivity">            <TextView              android:id="@+id/infoTextView"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:layout_marginBottom="30dp"              android:textSize="30sp" />            <EditText              android:id="@+id/editText"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:layout_below="@id/infoTextView"              android:enabled="false"              android:gravity="bottom"              android:lines="2"              android:maxLines="2"              android:textSize="20sp" />            <Button              android:id="@+id/buttonSeven"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_below="@id/editText"              android:text="7"              android:textSize="20sp" />            <Button              android:id="@+id/buttonEight"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_below="@id/editText"              android:layout_toRightOf="@id/buttonSeven"              android:text="8"              android:textSize="20sp" />            <Button              android:id="@+id/buttonNine"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_below="@id/editText"              android:layout_toRightOf="@id/buttonEight"              android:text="9"              android:textSize="20sp" />                    ...                    ...            <Button              android:id="@+id/buttonDot"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_below="@id/buttonOne"              android:text="."              android:textSize="20sp" />            <Button              android:id="@+id/buttonZero"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_alignRight="@id/buttonEight"              android:layout_below="@id/buttonTwo"              android:text="0"              android:textSize="20sp" />            <Button              android:id="@+id/buttonEqual"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_alignRight="@id/buttonNine"              android:layout_below="@id/buttonThree"              android:text="="              android:textSize="20sp" />            <Button              android:id="@+id/buttonDivide"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_alignTop="@id/buttonNine"              android:layout_toRightOf="@id/buttonNine"              android:text="/"              android:textSize="20sp" />            <Button              android:id="@+id/buttonMultiply"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_alignTop="@id/buttonSix"              android:layout_toRightOf="@id/buttonSix"              android:text="*"              android:textSize="20sp" />            <Button              android:id="@+id/buttonSubtract"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_alignTop="@id/buttonThree"              android:layout_toRightOf="@id/buttonThree"              android:text="-"              android:textSize="20sp" />            <Button              android:id="@+id/buttonAdd"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_alignTop="@id/buttonEqual"              android:layout_toRightOf="@id/buttonEqual"              android:text="+"              android:textSize="20sp" />            <Button              android:id="@+id/buttonClear"              style="@style/Widget.AppCompat.Button.Borderless"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_alignRight="@id/buttonAdd"              android:layout_below="@id/buttonAdd"              android:layout_marginTop="@dimen/activity_vertical_margin"              android:text="C"              android:textSize="20sp" />      </RelativeLayout>  </layout>  

Calculator internals

Our calculator has two values, valueOne and valueTwo. These values hold the numbers to be operated on. Both values are of type double, so they can hold numbers with and without decimals. We set valueOne to the special Double value NaN (not a number) for reasons that will be clearer below.

      private double valueOne = Double.NaN;      private double valueTwo;  

This simple calculator can only perform operations of either addition, subtraction, multiplication or division. So we define four static chars to represent these operations, and a CURRENT_ACTION variable, which holds the next operation we intend to perform.

      private static final char ADDITION = '+';      private static final char SUBTRACTION = '-';      private static final char MULTIPLICATION = '*';      private static final char DIVISION = '/';        private char CURRENT_ACTION;  

Finally, we use the DecimalFormat class to format the output of our calculator. The decimal format constructor permits displaying up to ten decimal places.

          decimalFormat = new DecimalFormat("#.##########");  

Handling button clicks (numbers)

Whenever the user clicks a number (or dot), we simply want to add that number to the editText. The code sample below shows how we accomplish this for number zero (0).

          binding.buttonZero.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View view) {                  binding.editText.setText(binding.editText.getText() + "0");              }          });  

Handling button clicks (operators)

Simple Calculator - with calculation

Handling clicks on operators is a little different. We would like to perform any pending computations first. So we define a computeCalculation method. Within computeCalculation, if valueOne is a valid number, we read valueTwo from the editText, and perform the current queued operation. On the other hand, if valueOne is NaN, valueOne assigned the number in the editText.

      private void computeCalculation() {          if(!Double.isNaN(valueOne)) {              valueTwo = Double.parseDouble(binding.editText.getText().toString());              binding.editText.setText(null);                if(CURRENT_ACTION == ADDITION)                  valueOne = this.valueOne + valueTwo;              else if(CURRENT_ACTION == SUBTRACTION)                  valueOne = this.valueOne - valueTwo;              else if(CURRENT_ACTION == MULTIPLICATION)                  valueOne = this.valueOne * valueTwo;              else if(CURRENT_ACTION == DIVISION)                  valueOne = this.valueOne / valueTwo;          }          else {              try {                  valueOne = Double.parseDouble(binding.editText.getText().toString());              }              catch (Exception e){}          }      }  

For every operator, we call computeCalculation() first, then set CURRENT_ACTION to the selected operator, while for the equals '=' operator, we call computeCalculation(), then clear the contents of both valueOne and CURRENT_ACTION.

          binding.buttonAdd.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View view) {                  computeCalculation();                  CURRENT_ACTION = ADDITION;                  binding.infoTextView.setText(decimalFormat.format(valueOne) + "+");                  binding.editText.setText(null);              }          });            binding.buttonSubtract.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View view) {                  computeCalculation();                  CURRENT_ACTION = SUBTRACTION;                  binding.infoTextView.setText(decimalFormat.format(valueOne) + "-");                  binding.editText.setText(null);              }          });            binding.buttonMultiply.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View view) {                  computeCalculation();                  CURRENT_ACTION = MULTIPLICATION;                  binding.infoTextView.setText(decimalFormat.format(valueOne) + "*");                  binding.editText.setText(null);              }          });            binding.buttonDivide.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View view) {                  computeCalculation();                  CURRENT_ACTION = DIVISION;                  binding.infoTextView.setText(decimalFormat.format(valueOne) + "/");                  binding.editText.setText(null);              }          });            binding.buttonEqual.setOnClickListener(new View.OnClickListener() {              @Override              public void onClick(View view) {                  computeCalculation();                  binding.infoTextView.setText(binding.infoTextView.getText().toString() +                          decimalFormat.format(valueTwo) + " = " + decimalFormat.format(valueOne));                  valueOne = Double.NaN;                  CURRENT_ACTION = '0';              }          });  

Congratulations! You have completed your simple calculator Android app.

Finally

If you run and use the above app, you will notice some possible areas of improvements, such as 1) click an operator when the editText is clear (i.e. without entering a number first), 2) allow the user continue calculating after clicking the equals button.

As always, the complete source is available on github, and you are free (nay encouraged) to modify, and use, to your heart's content. Hola in the comments if you found this useful, and/or want to recommend an app for a future tutorial.



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

Google Pixel now has a 5-week waiting time or is out of stock

thumb google pixel and pixel xl hands on aa no watermark

Given Google's big marketing push, it was expected its Pixel phones would achieve some lofty initial sales figures; judging by the estimated delivery times of the phones in the Google Play Store, they appear to have done just that.

The limited edition 'very blue' Pixel model sold out quickly and now both the 32GB black and silver versions have an estimated delivery time of November 23-25 with standard shipping. Meanwhile, the Pixel XL, the larger of the two devices, is completely out of stock in all variants with no indication as to when they will be available again.

google pixel and pixel xl first look hands on aa-42See also: Google Pixel International Giveaway!103

No doubt the Pixel and Pixel XL stock will be replenished in time for the holiday season. Still, you might be lucky to get the one you want before December.

Google's new Pixel phones replace the Nexus series as the search giant's home-grown handsets. Featuring Android Nougat out-of-the-box, the new flagships – built in partnership with HTC – also arrive with Google's new digital assistant and what could be the finest smartphone camera ever.

Our full Pixel review is on its way soon. In the meantime, check out our hands-on Google Pixel and Pixel XL impressions.



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

HTC throws another $100 million into the Vive X accelerator pot

HTC-Vive-12

This article originally appeared at our sister site, VRSource.

HTC has announced another major investment into its Vive X accelerator program, to the tune of an additional $100 million. This marks the second stage of the Vive X program, which was initially launched back in August with an original $100 million cash pot.

The Vive X program aims to help "cultivate the VR industry and the development of the ecological business", and fund virtual reality start-up companies around the world. Of course, it also helps build more use cases and content for its Vive headset too. HTC has already begun taking applications for the second phase of the program, and applications will run until December 1st 2016.

As well as the financial perks, successful start-ups will also be offered the opportunity to work at Vive X accelerator locations around the world. There's also a wealth of information to be tapped into from HTC's connections with leading VR experts, cutting edge technological developments, and mentorship programs. HTC expects this program to continue to grow in the coming months and years, with new locations coming to Europe in the near future.

hp-vive VR bundleSee also: HTC and HP are offering a Vive VR bundle for $1,4999

So far, HTC has backed more than 30 virtual reality start-ups from its Batch I of funding. The lists includes Action Bunker VR, LumiereVR, Directive Games, EdSenses, Shortfuse, CleVR and SurrealVR and Teemew.

Applications for Batch II of the Vive X program are now open and can be filled in over at the official website.



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