Skip to content

Archive for

30
Jun

Writing your first Android app – everything you need to know


There are lots of reasons why you might want to write an Android app. Maybe you have a great idea and you want to build a prototype, maybe you just want to learn to program for Android, maybe it is part of a school or college course, or maybe you are just curious. Whatever the motivation, building Android apps can be fun and rewarding.

In this tutorial we go through the steps needed to build your very first Android app. But before we start, it is worth mentioning some of the other resources we have related to writing Android apps. You should read I want to develop Android Apps – What languages should I learn? and Java basics: a tutorial for beginners.

Android Studio

To write an app you are going to need to download and install Android Studio. Included in the download are the Software Development Kit, with all the Android libraries and bits that you need to develop an app; and the Android emulator, so that you can initially test you app on your PC without needing to install it on a real device.

However, first you are going to need to download and install the Java Development Kit (JDK) from Oracle. Look for the section called “Java SE Development Kit 7u79″ and download the version for your PC. It is important that you download the right version (32-bit or 64-bit) because if you don’t you can have problems with Android Studio not finding the Java Runtime Environment (JRE).

Note: Oracle will not be posting any updates of Java SE 7 to its public download sites and it is suggested that users move to Java 8, however at the moment Android Studio requites Java 7. This could change in the future.

Once you have installed the JDK you should then install Android Studio. During the install you will need to configure how much memory to reserve for the Android emulator. The emulator runs Android in a kind of virtual machine, as an Android phone with an Intel processor. This is faster than emulating an ARM processor on your PC. However to run this virtual machine the emulator needs to allocate some memory. The installation program will recommend how much memory to reserve and it is probably best to accept the default. However, be aware that the combination of Android Studio, Java, and the emulator can be quite memory hungry, and your PC will slow to a crawl unless you have lots of RAM. Google says that you need 2 GB of RAM as a minimum, and that 4 GB of RAM is recommended, however my main PC has 8GB of RAM and sometimes it struggles!

android-studio-emu-setup

When you first run Android Studio it will perform some initialization including downloading and installing the latest Android SDK. This can take several minutes, you will just need to be patient.

When everything has been downloaded (and whenever you subsequently start Android Studio) you will see a menu which allows you to start a new project, open an existing project, import a project, and so on.

Start a new project

Click “Start a new Android Studio project” and enter a name for your app in the “Application name:” field, I would suggest something like “My First App” (without the quotes). In the “Company Domain” field enter the domain name of your company. If you are an independent developer or a hobbyist, enter your domain name. If you are just experimenting with Android and won’t be publishing your apps on Google Play anytime soon, then just leave the domain as it is, just change “user” to your name (without any spaces).

android-studio-new-project

On the next dialog make sure “Phone and Tablet” is selected and that the “Minimum SDK” is set to API 15: Android 4.0.3. Make sure that “Wear” and “TV” are not checked.

On the “Add an activity to Mobile” dialog,use the default of “Blank Activity” and click “Next.” On the “Customize the Activity” dialog use all the default values and click “Finish.”

android-studio-customize-activity

The Integrated Development Environment (IDE) will now start. This can take several minutes (especially if it is the first time you have created a project). If when the IDE appears you see an error message, “Rendering Problems: Rendering failed with a known bug” then click the “rebuild” link as indicated next to the error.

The default workspace for the IDE is split into three main parts (excluding the toolbars etc). On the upper left is the project tree. To its right is the code editor/designer, and beneath them both are the messages.

At this point it is possible to compile and run the auto-generated app, but it isn’t very interesting and you won’t learn anything about writing an Android app. So instead we are going to add a few little things, not much, but enough to get you started and give you a taste of Android app development!

The project tree

The project tree holds all the different files and resources that are needed to build your Android app. If you are familiar with writing simple programs in Java, C, Python, etc you might think that everything will be contained in just one or possibly two files. However Android app development is a little more complex, however this initial complexity is actually very useful once you start to write your app in earnest.android-studio-project-tree-expanded-840x482

Under the “app” node in the project tree you will see several nodes (like folders) which can be expanded. The top level nodes are “manifests”, “java”, and “res”. The last one is short for “resources.”

Under manifests you will find the file “AndroidManifest.xml,” every application must have one of these. It is an XML file with information about the app including its name. One of the most common things you will add to this file is the list of permissions needed by the app. For this simple test app you won’t need to change anything here.

Under “java” you will find the Java code for the app. It will be under a sub folder called something like “com.example.user.myfirstapp”, which is the reverse of the company domain name you entered earlier, plus the name of the app. Under that folder you will find MainActivity.java. This is the entry point into your app and for our example app this is the only Java file that we will need.

Under “res” there are several different folders for graphics, menus, and the UI. The two that interest us for this example app are “layout” and “values.” Under “layout” is a file called “activity_main.xml.” It is an XML file that describes the user interface. There are two ways to edit this file. The first is to edit the XML code directly, or the second is to use the built-in UI designer.

android-studio-act_main_xml

The “values” folder contains several different XML files, the most important one for this example app is “strings.xml.” Rather than hard coding string values into the Java code, the values are placed into the “strings.xml” file and then referenced using an ID. The advantage of this system is that if a string is used multiple times it can be changed in just once place. It also makes it easier to support multiple languages in the app.

To create this sample app we will need to modify MainActivity.java, activity_main.xml, and strings.xml.

Writing the app

For our example app we will add a Button with the label “Tap Me!”, we will change the default “Hello world!” label to “Tap me if you dare!” plus change its position so that it is in the center. And finally, we will add some code to display a “toast” when the button is tapped!

Let’s start by altering the text of the label and changing its alignment. First find “activity_main.xml” in the project tree and double-click it. Remember, “activity_main.xml” is the file which holds the User Interface definition. At the bottom of the code window there are two tabs, “Design” and “Text.” Make sure you are using the “Design” tab.

Now click in the text “Hello world!” that is shown on the rendering of the phone. If it is too small use the zoom button (the plus sign in a magnifying glass) to enlarge the rendering of the phone.

In the “properties” window just to the right of the phone image, scroll down until you find “layout:centerInParent.” Click the space next to it and select “horizontal.” The “Hello world!” text will now jump to the horizontal center.

android-studio-hello-world-align

Now to change the text. The string “Hello world!” is held in the file “strings.xml” under res->values. If you double-click on the file you will see a few lines of XML that defines the the strings used by the app. Find this line:

<string name="hello_world">Hello world!</string>

And change it to

<string name="hello_world">Tap me if you dare!</string>

To recap. We have aligned the text on the horizontal center and we have changed the text. Now to add a button. Back on the “Design” tab of “activity_main.xml,” find and click on “Button” in the “Palette” list to the left of the phone render. Now click somewhere beneath “Tap me if you dare!” on the phone image, make sure it is in the middle.

Now double-click on the button so that you can change the text. The quick and dirty way is just to change the text and leave it hard coded. However since we have already been introduced to “strings.xml” we should continue using it, as a best practice. At the end of the “text:” field is a button with three dots, click it. In the “Resources” windows click on “New Resource” and then on “New String Value…” In the “Resource name:” enter “tapme” and in the “Resource value:” enter “Tap me!”. Then click OK. The button will now say “Tap me!”

The final step is to add some Java code which reacts to the button being tapped. One of the UI elements of Android is a “toast.” A toast provides simple feedback in a small popup. You will certainly have seen it. For example, in Gmail navigating away from an email before you send it triggers a “Message saved as a draft.” Toasts automatically disappear after a timeout.

For our sample app we will display a toast every time the button is tapped. The first step is to add some Java code. Find MainActivity.java and add the following code beneath “onCreate”:

public void onButtonTap(View v) 
        Toast myToast = Toast.makeText(getApplicationContext(), "Ouch!", Toast.LENGTH_LONG);
        myToast.show();

The word “View” in “(View v)” will likely be in red with a message bubble displayed near it. This is Android Studio telling you that you have used a new construct (View) without importing it in the import section, at the top of the Java code. This is easy to fix. Click on the word “View” and then press ALT+ENTER, Android Studio will fix it for you! If the word “Toast” is in red, then do exactly the same thing again. Click on the word Toast and then press ALT+ENTER.

android-studio-set-onButtonTap

Now back in the designer for “activity_main.xml”, click on the button and scroll down through the properties list until you find “onClick”. Click on the box to the right and a list of functions will appear. Click on “onButtonTap”, the function we just added.

So now the “onButtonTap()” function will be called whenever the button is tapped. When it is called it creates a Toast called myToast that will display the message “Ouch!”. To show the Toast we just call myToast.show().

And that’s it, in terms of writing our app, now to test it in the emulator.

Building and testing your app

Under the Tools menu, navigate to Android -> AVD Manager. This tool shows you the list of currently configured Android Virtual Devices. You will have one device configured by default, probably a Nexus 5. Click on the play icon (the triangle) under the actions column. This will start the emulator.

Depending on the performance of your PC and the amount of memory you have, the emulator can take several minutes to start up. Once the emulator is up go to the Tools menu and click on “Run ‘app’”. This will compile the app and send it to the emulator. During this process Android Studio will ask you which emulator to use. You will see your running emulator in the list, it should be the default option, so just click OK.

android-studio-my-first-app-in-emu

The app will appear in the emulator (eventually). Click on the “Tap me!” button and watch for the toast to appear towards the bottom of the emulated device. Congratulations!

What to do next and wrap up

It is also possible to run the app on a real device. The easiest way to do this is to enable “USB debugging” on an Android device and connect it to your PC. The USB debugging option can be found under Settings>Developers options. If you don’ t have a Developers options section then open Settings> About and then tap “Build number” seven times.

With the device connected click on  “Run ‘app’” under the Tools menu, but this time don’t send the app to a virtual device, send it to a real device. If your device isn’t listed it either means that you haven’t enabled USB debugging or you need to install the appropriate USB driver for your device. See the OEM USB Drivers and Google USB Driver sections in Google’s documentation.

Obviously this is just the beginning, but you have successfully created a real Android app with some user interaction. The next thing to do is write your second app and keep going. Google has a lot of Android developer training material, plus there is extensive documentation, and lots of code samples.

You should also subscribe to the Android Authority Dev Weekly newsletter. It is a curated publication full of interesting, relevant links for Android developers. You should also check out the other developer related articles on the Android Authority website, you will find the more technical developer articles in the Android Development category, while general developer focused articles will be tagged for developers.

But most of all you should have fun and keep learning!

30
Jun

Motorola says the DROID Turbo Lollipop update is coming soon


With the original Moto X, Motorola showed customers that it could be just as fast as Google at releasing system updates to its flagships. However, their beastly DROID Turbo has been almost a completely different story.

With a near-stock Android skin, many believed the Turbo would receive the same quick updates that were seen with the Moto X, but with Android M just around the corner, the Turbo is still missing the taste of Lollipop.

Thankfully, that should all soon change. Motorola took to Twitter and announced that Android 5.1 is ready and will be “coming to a DROID Turbo near you.” The Turbo has recently started a soak test, but this tweet means that the full OTA update is just around the corner, hopefully.

As with some of their other phones, Motorola has decided to skip Android 5.0 and update directly to 5.1.While this will come to excitement of Turbo owners, it begins to raise another question. Will Android M take just as long to arrive on their device?

Currently, there is no way to tell. The DROID Turbo is a Verizon exclusive, and they are not known for their timely updates, plus the Turbo will be last year’s product by then. Hopefully, Turbo owners will not have to endure such a long break between updates next time, but if the present is anything to go on, they should not start to get their hopes up.

If you own a DROID Turbo, are you excited about Motorola’s announcement? Let us know in the comments!

 

 

Source: Twitter via: PhoneArena

The post Motorola says the DROID Turbo Lollipop update is coming soon appeared first on AndroidGuys.

30
Jun

Huawei Honor 7 launched with in metal starting at $322


The much anticipated Honor 7 was just announced today during Huawei’s official press event. Actually, three Honor 7s were announced today. All of them were decked out in an all metal build.

Variants

The base model will ship with 16 GB of memory and LTE. A step up will lend you a dual SIM model and the top tier will ship with 64 GB of storage.

Each model will cost about $322, $355 and $400 respectively.

Display

The Honor 7 sports a 5.2-inch screen with a resolution of 1920 x 1080 yielding a PPI of 423.

honor7
honor7_2
honor7_1

Processor

Powering that 5.2-inch screen is a octacore Kirin 925 processor. The Kirin is clocked at 2.2 Ghz. The chipset is made up of eight A53 cores. Four are clocked at 2.2 Ghz, and four more are clocked at 1.5Ghz.

Backing the Kirin 925 is a Mali T628 GPU.

Camera

In the camera department, the Honor 7 shows off a 20 mega-pixel rear camera with “Phase Detection Auto Focus” that will supposedly give you a 0.1 second focus time. This shooter also has a F2.0 aperture and 6  lens made out of sapphire glass.

Over on the front is a more modest 8 MP camera that has a fixed focus and F2.4 aperture.

Memory

Following today’s standards, the Honor 7 will ship with 3 GB of RAM. As stated before, the base model will contain 16 GB of internal storage for about $322 with the option to grab a 64 GB model for around $400.

Don’t worry if you can’t afford a 64 GB model though. Huawei has included a SD card slot with support for up to 128 GB microSD cards.

Battery

What good is a phone if it is dead? Huawei asks the same question and answers it with a 3100 mAh battery powering the Honor 7.

This battery supposedly will reach a full charge in a mere 1 hour and 25 minutes. Don’t have time for that you say? Well don’t worry, you can get up the a 50% charge in just 30 minutes.

If you don’t have 30 minutes to charge your phone, then I would say you have bigger problems then trying to find a way to keep your phone alive.

Although not specifically mentioned by our source, it would appear that the battery is non-removable as a consequence of the beautiful all metal body.

Connectivity

The Honor 7 will sport NFC, WiFi (802.11 a/b/c/g/n/ac) with support for both 2.4 and 5 Ghz bands, Bluetooth 4.1, GPS, GSM, WCDMA and LTE.

Bands are, of course, dependent on your region.

Fingerprint Sensor

That’s right, fingerprint sensor. Huawei has equipped their latest device with a fingerprint sensor on the back of the device right under the camera.

This sensor will allow for one touch unlock. Huawei has also baked in various apps for banking and additional payment methods that will utilize the fingerprint sensor for security purposes.

Honor 7 comes with Fingerprint Cards AB (FPC)’s FPC1025 fingerprint sensor. A step up from the FPC1020 that can be found in Huawei’s Ascend Mate 7.

Gotta love those product names.

In a statement from FPC’s CEO, we learn that the FPC1025 is capable of 360 degree finger rotation.

Huawei is a leading global smartphone manufacturer and we are proud that Huawei selected FPC1025 for Honor 7, following up on the great success of Huawei Ascend Mate 7 with FPC1020 embedded that was launched in 2014. FPC1025 supports 360 degree finger rotation capability, fast response time and industry leading 3D image quality.

Wrap Up

The Huawei Honor 7 comes in at 143.2 x 71.9 x 8.5 mm and weighs 157 grams. Running EMUI 3.1 based off of Android 5.0, the Honor 7 packs quite a punch on paper.

For a base price of $322, the Huawei’s latest offering comes with near top of the line specs and a killer camera for half of what current flagships go for.

Hopefully the device will meet our expectations and deliver top grade performance for one of the cheapest prices out there.

Let us know in the comments down below what you think of Huawei’s newest device. Will you be getting it?

Source: GizChina via: PhoneArena

The post Huawei Honor 7 launched with in metal starting at $322 appeared first on AndroidGuys.

30
Jun

New Galaxy S6 buyers get 6 free months of Google Play Music


Google recently announced a free, ad-supported version of their Play Music service. It is a great, cheap way to enjoy music, but it is currently non-existent in Canada.

Thankfully, Samsung has a deal that is sure to excite users there. For a limited time, new Galaxy S6 buyers will get to use Google Play Music free for six months. A subscription to Google Play Music gives you access their 30 million song library, radio stations, playlists for any time of the day, and the option to add up to 50,000 of your own songs to your library.

If you would rather purchase a different Samsung phone, the company has extended the deal to their other phones but has dropped the free period from six months down to three months. This means that users from Canada can pickup a new Samsung phone and enjoy at least a few months of Google Play Music.

The ad-supported stations are supposed to become available in Canada before too long, but you can start enjoying your tunes now. For those in the market for a new phone, this new offering from Samsung is sure to sway some buyers towards the company’s newest flagship.

Unfortunately, this offer is only for our friends in Canada, but we have to let them have somethings, eh?

Will you be taking part in this deal and grabbing up a new Samsung phone? Tell us in the comments!

Source: MobileSyrup via: PhoneArena

The post New Galaxy S6 buyers get 6 free months of Google Play Music appeared first on AndroidGuys.

30
Jun

Samsung Galaxy S6 sales are not looking so good anymore, Galaxy Note 5 to be the new saviour






style=”display:block”
data-ad-client=”ca-pub-8150504804865896″
data-ad-slot=”8461248232″
data-ad-format=”auto”>
(adsbygoogle = window.adsbygoogle || []).push();

It previously seemed like Samsung was making a return to prominence with its release of the widely acclaimed Samsung Galaxy S6 and Galaxy S6 Edge smartphones. However, a report today paints a very different picture for the Korean manufacturer, saying that while Samsung Galaxy S6 sales have spearheaded an estimated 22% increase in profit quarter on quarter, the year on year figure has actually dropped 24% – when you consider that one year ago was in the Galaxy S5’s heyday, that becomes extremely surprising.

As a result of this, the report says that Samsung is now banking on the Galaxy Note 5, expected to be announced at IFA 2015 in September, to do most of the heavy financial lifting in the latter part of the year. Samsung is also expected to be launching the Galaxy S6 Edge Plus, a larger, phablet-sized version of the Galaxy S6 Edge sometime in the coming weeks. The report also depicts a similar story for LG and its recently launched LG G4, which, more than anything, depicts a smartphone market that is incredibly hard to predict these days no matter how good the devices are.


What do you think about Samsung Galaxy S6 sales? Let us know your thoughts in the comments below.

Source: Business Korea via SamMobile

The post Samsung Galaxy S6 sales are not looking so good anymore, Galaxy Note 5 to be the new saviour appeared first on AndroidSPIN.

30
Jun

Mojang retires its card battle game, offers one more year of playtime


Mojang means Minecraft. But that’s not the only thing the Microsoft-owned developer tinkers away at. Scrolls was another project: an online card-based battle game that’s available across PC, Mac and tablets. Unfortunately, the title has reached the end of its life, with the developer announcing that it will discontinue work on the game. It doesn’t offer up a particular reason for the quiet ending, but we’ve reached out to see if there was any particular reason — the developer claimed a legal victory against Bethesda in being able to name the game “Scrolls” in the first place, but was bound from naming any sequels similarly. Mojang promises that it’ll keep the servers running for another year, so that’s twelve more months to tackle the latest update and levels, which were released only last month.

Filed under: Gaming, Microsoft

Comments

Source: Scrolls

30
Jun

NYT: AC/DC’s dirty deeds coming to Apple Music and Spotify


ACDC Perform in Concert in Madrid

Seeing as how it’s impossible to write a three-chord intro with words, this sentence is just going have to do for now: AC/DC is coming to Spotify and Apple Music. The Australian rock group’s catalog will go on the aforementioned streaming services in addition to Rdio starting tomorrow, according to The New York Times. In case you’ve sworn off classic rock radio, Brian Johnson and Angus Young’s tunes should help fill in the gaps between Led Zeppelin and Pink Floyd in your playlists. Just think, there’s a very real chance that tomorrow you’ll be able to shake it off all night long.

Filed under: Internet

Comments

Source: The New York Times, Associated Press

30
Jun

PIQ golf sensor marries swing tracking with game analysis


There are golf sensors out there that track your swing and others that give you yardage and stats, but wouldn’t it be nice to have one that did both? That’s the theory behind the PIQ golf sensor, which comes equipped with NFC, GPS, Bluetooth and a 13-axis motion sensor. For distance measuring, the company says it has the “lightest and sleekest GPS rangefinder” out there that clips onto your glove. A bright LED display will give you the distance the front, center and back of the green, so that you don’t have to pull out a smartphone or wear a custom watch. Thanks to a deal with golf outfit Mobiltee, it can automatically figure out where you are from its 35,000 course database.

The device also measures your swing metrics for each shot, including clubhead velocity, height, air time and more. To tell it which club you’re using, it comes with 18 NFC tags that attach to the grip in a very similar way to Game Golf’s NFC tagging setup. You just tap your club to the PIQ sensor prior to each shot, then it’ll record your swing data and transfer it via low-energy Bluetooth (BLE) to your smartphone. At the same time, it’s recording the distance of every shot you hit and where you hit it from so that you can analyze your round later.

Putting the two together, you can not only see that you hit a seven-iron out of the rough and onto the green, but also what clubhead speed and face angle you used to pull it off — a wealth of info for serious golfers. (And most of us are pretty serious.) To analyze your swing and chart your progress, PIQ says you’ll get unlimited access to Mobitee and its own apps. It’ll also reveal similar swing trackers for two other sports later in the year. for If you’re interested, the device is now up for pre-order in Europe for a limited time at 199€, rising to 269€ later on. It’ll ship to customers in September, just before it arrives in retail stores. We’re not sure about US availability, but will let you know once we have more info.

Filed under: Wearables

Comments

Source: PIQ

30
Jun

Samsung’s Galaxy A8 gets manhandled in Quick Start video prior to its release


Galaxy A8 (2)

We’ve heard rumours for a couple of months now that Samsung were in the process of readying its Galaxy A8 smartphone for launch, and this is surely the clearest hint yet. A quick start video has been released of the handset being manhandled by China’s TENAA (China’s version of the FCC), showing off its various features and specifications.

We have the video below, but first, let’s have a look at the Galaxy A8’s specifications:

  • Android 5.1.1 Lollipop
  • 5.7-Inch Full HD Super-AMOLED display (386ppi)
  • Snapdragon 615 Quad-core processor
  • 2GB RAM
  • 16GB Internal Storage
  • MicroSD card support
  • 16MP Rear camera
  • 5MP Front camera
  • Home button with fingerprint sensor
  • 4G/LTE
  • Battery: 3,050mAh
  • Dimensions: 157.7 x 76.7 x 5.9mm

Besides having a thickness of just 5.9mm, the Galaxy A8 also continues the A Series trend of having a metal frame. No details are known about the Galaxy A8’s pricing and availability just yet, although it’s thought that Samsung won’t be waiting too long to make a formal announcement in the next few weeks. Don’t forget to have a look at the video below, the Galaxy A8 is a handsome enough smartphone with some very handy specs.

Click here to view the embedded video.

Source: NoWhereElse

Come comment on this article: Samsung’s Galaxy A8 gets manhandled in Quick Start video prior to its release

30
Jun

Roaming charges to be scrapped in the EU


european union eu flag 

The European Commission has been gradually chipping away at data roaming costs within the European Union and has now decided to abolish roaming charges on the continent on June 15th 2017.

The new rules state that customers on EU based operators will pay the same amount across the Union as they do in their home country. However, there was potential for an exploit here, whereby customers in one country could buy a cheaper SIM deal from abroad in order to achieve cheaper rates. To combat this issue, the Commission has ruled that there will be a limit to the amount of roaming data and calls that are free before a carrier can begin charging any additional fees.

When travelling in the EU, mobile phone users will pay the same price as at home

Sadly, the summer of 2017 is still quite a way away. Until the new rules come into force, the Commission will be imposing another interim cap which will begin from April 2016.

Carriers will be limited to charging customers a maximum of €0.20 per MB, €0.06 per SMS and €0.05 per minute when roaming abroad, which is about 75 percent cheaper than the current cap.

Online content will not be unfairly blocked or slowed down anymore, and paid prioritisation will not be allowed

The Commission also has some tougher net neutrality rules on the way too. Beginning April 30th 2016, ISPs on the continent will be prevented from throttling speeds or blocking access to any online content, apps or other services.

However, blocks in the name of network security and combating child pornography are exempt. It will be interesting to see how this affects some national government efforts to block access to video and torrent sharing websites.

Internet “fast lanes” have also been ruled out, with the exception of parts of a network reserved for higher quality “innovative services” and Internet TV, so long as these don’t affect other people’s access to regular internet services.

The rules still have to be put into writing, signed off on by the European Parliament and Council, and then translated into all the various languages, which is partly why these rules are going to take a bit of time to implement. Still, I’m sure an end to data roaming charges and increased internet neutrality protection will be well received when they finally arrive.