Slatedroid info

Everything about android tablet pc [slatedroid]

Google Play Services 7.8 Rolling Out, Includes Mobile Vision API and Nearby Messages API

Posted by Tim-o-tato August - 14 - 2015 - Friday Comments Off

Google Play Services 7.8 is now rolling out for developers, continuing its mission in allowing developers to “build better apps.” In this release, Google has new APIs that focus on its previously released Nearby Connections API, as well as a new API called Mobile Vision

In the Mobile Vision API, developers can use the Face API to build applications that not only detect faces, but can recognize if a subject is smiling or not, and to what degree. Smiles are measured from 0.0 to 1.0, with a frown being 0.0 and a full teeth-grinning smile rated at a 1.0. In the below video, Google’s Magnus Hyttsten shows a great example of this Mobile Vision API in action. Also included in the Mobile Vision API is a Barcode API, allowing applications to read barcodes during a live video.

In addition to Mobile Vision, Google introduced the Nearby Messages API, an extension to the existing Nearby Connections. With this, developers can create a bridge via WiFi or Bluetooth signals to multiple devices, allowing them to share a stream of information to one another.

Are you a developer? Check out Google’s video below, as well as the complete announcement on the Android Developers blog.

Via: Android Developers

Google Play Services 7.8 Rolling Out, Includes Mobile Vision API and Nearby Messages API is a post from: Droid Life

Google is adding two new beta testing methods for developers

Posted by wicked July - 30 - 2015 - Thursday Comments Off


Beta testing applications is a wonderful thing for developers on Android. It gives app makers an easy way to test out new features in the app before the update rolls out to everyone, and can also help prevent some major bugs. Previously, if you wanted to become a beta tester for an app on Google Play, you’d need to either join a Google+ Community or a Google Group, but that requirement is changing today.

Google has just added two new beta testing options for developers in hopes to bring more users on board. Both new options do away with the Google+ Community/Google Group requirement, which will hopefully make it easier for people to sign up. Here are the two new options:

  • The new open beta route will allow you to share a link with users that will take them right to the beta version of the app in just one click. This new method is meant for large-scale beta testing, but you can still limit the maximum number of users who can join, if you’d like.
  • If you’d like to more easily control the number of users who can access your beta, you can use the “closed beta using email addresses” route. For this method, you’ll need to invite users with their email addresses by adding them individually or by uploading a .csv file. This method won’t require you to put a G+ Community signup in place, either, but also won’t work well for large beta testing groups.

The current closed beta testing method isn’t going anywhere, so you’ll still be able to invite users to join Google+ Communities and Google Groups in order to download the new version of your app. For more information on these new testing methods, head to the source link below.

Alcatel OneTouch Idol 3 can finally be rooted

Posted by wicked July - 22 - 2015 - Wednesday Comments Off

alcatel onetouch idol 3 review aa (25 of 27)

Got yourself an Alcatel OneTouch Idol 3? Good choice! We named it one of the best budget phones of 2015 in our review, and now it can get even better. XDA’s developer community has finally achieved root, after having to wait a couple months after the phone’s release.

This comes as great news to OneTouch Idol 3 users who have been itching to tinker with the phone’s software. Those who have been following the progress will know achieving root on this smartphone became a bit of a complication, due to issues with entering fastboot mode. This was no hindrance to XDA users frankee207DallasCZ, and Gynoid, though. These guys worked their way around the obstacles by studying an exploit on phone with similar complications.

alcatel onetouch idol 3 aa 10

Disclaimer: Please keep in mind rooting, unlocking your bootloader or tinkering with your phone’s software in any way is not safe. There is a chance you could void your warranty or even damage your phone permanently. If you are to root your Alcatel OneTouch Idol 3, we advice that you be careful and do a fair amount of research before doing so, as only you will be held responsible for any issue you may encounter. 

Let us continue. All steps have been compiled, organized and published at a post from DallasCZ, so you can simply read his thread to see how you can finally gain access to your phone’s true potential.

alcatel onetouch idol 3 aa 3

This exploit works on the latest software version of the Alcatel OneTouch Idol 3. Keep in mind this solution has only been tested with the 5.5-inch version of the device. If you own the smaller 4.7-inch iteration, your best bet is to wait patiently.

With this out of the way, it is only a matter of time before ROMs for the Aclatel OneTouch Idol 3 start showing up. That’s when things will get more interesting! How many of you have been waiting for the Alcatel OneTouch Idol 3 to achieve root? Will you be going through this process?

Alcatel OneTouch Idol 3 in video

Twitter co-founder wants developers to come back 

Posted by wicked July - 15 - 2015 - Wednesday Comments Off

It wasn’t too long ago when Twitter decided that app developers were having too much fun with their data and decided to limit and even restrict access to their API, leading some of these third-party apps to eventually close down or morph into something totally different. But now co-founder and board member Evan Williams believes it’s time to mend the breach and ask developers back into the fold now that they have finally figured out more or less what Twitter really is: a realtime news platform.

The CEO-less social network/micro-blogging/news platform is first on everyone’s mind to check whenever there is an ongoing live event or when a breaking news occurs, as it has the most posts, pictures, videos, links to both rumors and facts (and yes, a lot of funny business on the side as well). But Williams is the first to admit that they need to offer users a better way of organizing, finding, and sorting through all that noise.

And the answer to that would probably be to connect once again with the software developers that they alienated a few years back. The move to restrict access to the API was one of the “strategic errors” that they have learned from. He hinted during his talk at the Fortune Brainstorm Tech conference that there are a lot of things going on in terms of product development and coming up with new sources of revenue, and it looks like the search for the new CEO may have to take a backseat to all these new things they’re looking into.

Dick Costolo resigned last month, after much pressure from investors who were unhappy with the revenue projections and quarterly reports. But Williams says, Twitter’s revenue stream is pretty good. I wouldn’t say we haven’t figured that out. The business is really solid.”

VIA: Business Insider

Writing your first Android app – everything you need to know

Posted by wicked June - 30 - 2015 - Tuesday Comments Off

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!


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).


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.”


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

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 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.


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, 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.


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 and add the following code beneath “onCreate”:

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

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.


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

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.


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!

Google announced big changes for developers today in a post to the official Android Developers blog, stating the company is to stop development and support for Android Developer Tools (ADT) in Eclipse at the end of this year. 

Over the next few months, Google will continue to improve upon Android Studio, its new go-to for app development. For developers, this means that it is time to migrate any existing Eclipse ADT projects into Android Studio. As Google notes, this process is very simple – File, New, Import Project in Android Studio.

As stated in the post by the Android Developers team, “We are focused on Android Studio so that our team can deliver a great experience on a unified development environment. Android tools inside Eclipse will continue to live on in the open source community via the Eclipse Foundation.”

If you develop, it’s time to migrate.

Via: Android Developers

Google to Stop Development and Support for Android Developer Tools (ADT) in Eclipse at End of 2015 is a post from: Droid Life

Should Google Open Up Android Wear?

Posted by wicked June - 10 - 2015 - Wednesday Comments Off

Android Bootloader

2014 was going to be the year of the wearable. And it was, insofar as it was the first year that I started to notice news headlines outside of the normal enthusiast channels, covering stories regarding these futuristic devices. Android Wear was released alongside Samsung’s Galaxy Gear, Google Glass became available to anybody, and even the long-rumoured Apple Watch was, at least announced. The previous year, the Pebble watch had shown the demand for something that could provide us with our notifications without having to remove our phones from our pockets by raising a record amount of funding on Kickstarter, and some rivals like Sony were already on their second generation of connected gadget. It seemed as if the technological world had consumed the smartphone, and was now ready and eager to move into the next course and digest the more enticing smart-watch.

2015 was also meant to be the year of the wearable. We’d seen the first fledgling efforts of the major players (sometimes the second, or third, even) and those who hadn’t immediately jumped on board the hype-train were patiently awaiting the next wave of devices, with all the expected refinements that would make this technology essential this time around. But that hasn’t exactly been the case.

I realize, of course, that we’re only half way through the year, and that anyone with an interest in this area is waiting for the new Moto 360, the Samsung Gear A, the Pebble Time, or even the plethora of existing watch manufacturers who are now trying their hand in the smart arena. The fact remains, however, that smartwatches are a nice thing to have, they’re just not completely necessary yet, even though they’re fun and you might miss them when they’re not there. There are a number of reasons for this, and they are issues that have been widely raised – the same issues for the most part that were predicted a few years back. Battery life has to be one of the most prevalent, with most smartwatches having to be charged nightly if used for much more than just glancing at the time. The size, weight and design of current models is still generally on the large or bulky side; after all, watches have been fashion accessories as much as timepieces for a couple of centuries. The aforementioned Moto 360 for example, did well mostly because it looked desirable, and despite the fact that it was released with some underwhelming or out of date internals (that now apparently don’t work very well with the Wear 5.1.1 update). The other thing to note, which hasn’t been fully realized yet due to the age of these gadgets, is the fact that these are essentially mini-computers we’re wearing and will need replacing every few years. They will become out-dated, or stop receiving software updates, or their batteries will suffer the ravages of the daily charge/discharge cycle. It’s hard to stay objective on this subject when you’re a developer with the latest gear and the people you speak to all the time are in the same frame of mind, but I believe these reasons, added to their collective price, have made smart-devices a tough choice for the average consumer.


But there’s a final point that I believe is worth raising (especially here on XDA) that may have been a notable cause of this lack of traction, and it pertains to Android Wear in particular. Google made an interesting choice when creating the current leader in wearable operating systems, by preventing OEM’s from modifying the software and creating their own flavors of it. I admit that this does make a lot of sense, providing not only a consistent user-experience across the board (important with a new platform), but also hugely assisting with the constant ordeal of software updates. But Android has always been open (for the most part), and the fact that smartphone manufacturers were given the freedom to create their own UI’s, add features, and generally demonstrate their own ideas of what the customer needed in a phone, meant that consumers were given a huge range of different options and price points, and had a better chance of finding the right fit for them. With Android Wear, we don’t have that; every smartwatch that runs it works in almost the exact same way, with the only differentiation being the hardware aspect. This means that Google has to directly drive the features that we see, and the options for developers are somewhat limited. Personally, the developers here at XDA are the main reason that I fell in love with Android in the first place; the sheer number of ideas floating around the forums is staggering! Someone, somewhere has managed to get almost every device running the current version of the OS regardless of its age, or its limited specifications, or in some cases, even whether it’s worth doing in the first place. Many of the features we now take for granted were pioneered by an independent developer or third party, and are only now making their way to vanilla Android. Some, like me, prefer the look and feel of an unmodified, Nexus-like experience, but you cannot deny what Samsung’s Touchwiz or HTC’s Sense has done for the adoption of Android as an operating system. You can root Android Wear, you can unlock the Bootloader, you can side-load apps and you can install a custom recovery, but then what? There is no Cyanogenmod for Android Wear, because we’re all running stock anyway, and at the moment it’s down to the developers to come up with apps, and apps only, to make these things sell.

Of course, it’s never going to be one single element that cripples a range of products, it’ll be a combination of a few, but perhaps it is this which is lacking with the current crop of smartwatches. I’ve definitely noticed it, but not everyone will, and it’s important to remember that often with OEM skins comes bloat, messy user interfaces and buggy software experiences. Customization is a corner-stone of Android, and without everyone being able to fiddle around with the software experience on their wrists, Google is, in one way, preventing developers and manufacturers from coming up with the kind of features that could potentially make this platform really attractive to a really important demographic; the first time buyer. Once those users are on-board this technology could really snowball. So perhaps it is up to Google to provide a little wiggle-room on the OS-front, whilst keeping the core experience clean and stable, thus providing a flexible product, great for the basic and advanced user alike. Hey, you can dream, right?


What do you think?  Let us know in the comments!

The post Should Google Open Up Android Wear? appeared first on xda-developers.

This is what the Android Nanodegree entails

Posted by wicked June - 2 - 2015 - Tuesday Comments Off


One of the ‘lesser’ announcements Google made at last week’s I/O 2015 keynote was the new Android Nanodegree, which aimed to offer a crash course in Android development and offer an insight into the lifecycle of Android app development. Today, the Redmond-based company has revealed exactly what the Nanodegree entails and if you’re interested in becoming a marketable Android developer, you’ll definitely want to read on.

Partnered with online education specialist Udacity, the Android Nanodegree program lasts for between six and twelve months at a cost of $200 per month. The course covers everything from the fundamentals of Android and app development to advanced development skills and also focuses on Google Play Services and Material Design.

Today’s update on the Android Developers blog reveals the finer details and one specific point; the Nanodegree contains the same courses that are individually available for free but subscribing to the Nanodegree “gives you access to coaches who will review your code, provide guidance on your project, answer questions about the class, and help keep you on track when you need it“.

The other element to the Nanodegree is that it’s based on the skills and projects in your portfolio and – unlike a traditional degree program – you can skip the courses that address the skills you already possess. As Google’s own post says:

You can focus on writing the code and building the projects that meet the requirements for the Nanodegree credential.

So what does the Android Nanodegree actually entail? Google has also outlined the individual courses that make up the degree:

Is the Nanodegree a good move by Google? It certainly is, for a couple of reasons: first, it offers developers the chance to gain a credential that can set them apart from other developers and secondly, it allows Google to train developers to create apps that meet its own standards. Given that the courses themselves are available individually for free, it remains to be seen how many people are willing to spent $200 per month to get access to help when they need it.

Google I/O 2015 in videos:

What do you think of the Nanodegree? Would you pay $200 per month for Google’s help to build your app and gain a credential that will allow you to market yourself better? Let us know your views in the comments below!

Google’s new app rating system now live on web, mobile

Posted by wicked June - 1 - 2015 - Monday Comments Off

A few months back, Google told developers that there will now be a new app rating system, based on which region you submitted the app to. The questionnaire that they submitted will be reviewed by the appropriate body and then the app will be given a rating, depending on the standards of that region. Now that rating system has gone live, on the web version, and is still rolling out to the mobile version of Google Play Store.

You’ll be able to see the new age and region appropriate ratings under the app ratings on the web version of the Google Play Store. They would vary sometimes depending on which region you submitted it to. For example, one of the review bodies is the International Age Rating Coalition and in the US, the ratings are as follows:

E – Suitable for all ages, but may also contain minimal, mild violence (as with cartoons, fantasy elements), and occasional use of “mild language”

E10 – For everyone, 10 and above

T – For teens, 13 and up. Content may include juvenile, crude humor, a little bit of blood, simulated gambling and “possibility of strong language”

M – For age 17 and up because it contains intense violence, sexual content, and strong language

AO – For adults only, ages 18 and up, because of the addition of graphic sex and gambling with actual money

Developers would have to fill up a content-related questionnaire before they submit their product to Google Play Store and then Google will pass it on to review bodies who will give the appropriate rating. Even existing apps had to have their content ratings done as well. The ratings are still rolling out for the mobile version of the Google Play Store but is already visible on the web version, if you’d like to check them out.

VIA: Android Central

Java basics: a tutorial for beginners

Posted by wicked May - 28 - 2015 - Thursday Comments Off

Update, May 28: Added video.

Original post, April 17: If you have ever wanted to write your own Android app, for fun or for profit, you are probably going to need to do some programming. There are lots of different ways to write Android programs but the official language of Android is Java. If you don’t want to try your hand at Java, then I would recommend you read my article: I want to develop Android Apps – What languages should I learn?

Not only is Java the official programming language for app development, Java itself is used by Google for large parts of the Android internals. There are two distinct parts to writing an Android app. One is the Java programming language itself, the other is understanding how to create an app in terms of its user interface, the Android OS, and the Android Software Development Kit (SDK). In this tutorial we will deal with the first of these, the Java programming language.


To start writing Java programs you need a way to compile source code and turn it into an executable for the Java runtime.

Java was first released in the mid-1990s by Sun Microsystems. It was designed to be easy to learn by programmers who already knew C and C++. During 2006 and 2007 Sun released Java as free and open-source software, under the terms of the GNU General Public License (GPL). Sun was bought by Oracle in 2009/2010, and Oracle remains committed to Java.

To start writing Java programs you need a way to compile source code and turn it into an executable for the Java runtime. The normal way to do this is to install the Java Development Kit. At the time of writing the current version of Java is Java 8, however it is relatively new, so Android uses Java 7. If you are unsure about installing the JDK then read this How to Install the Java Software Development Kit tutorial. Oracle also provides a JDK 7 Installation Guide.

However, if you aren’t quite ready to install the JDK, and you want a quick route to trying your first Java program, then I recommend Koding gives you access to a free virtual machine with all the compilers and tools you need to compile and run Java programs as well as develop in other languages like Go, Python, Node, and C. To sign up just visit, type in your email address and a password of your choice, and then click “Sign Up”.

The virtual machine (VM) comes with an IDE and command line access. The web view of the virtual machine is divided into four. On the very left if the Koding control panel with access to your account details, the virtual machines you have created and so on. Next to it is a file manager which shows all the files and folders you have on your VM. Next to that the screen is split into two. The top half is an editor, for writing your code; and the bottom half gives you command line access.

From here in I will assume you are using Koding. However, for those who have installed the JDK the process is almost identical except that you will need to use a text editor on your PC rather than the editor inside the Koding IDE.

Cut and paste the following code into the editor:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");

And save it as In Java the filename of the source code and the class name must be the same. The first line of the code declares a class called HelloWorld, so this source code must be saved in

In Koding to save the file, hover the mouse over the tab for the code (probably called Untitled.txt) and click on the little arrow. Then click “Save As…”, enter as the file name and click “Save”.

At the bottom part of the screen is the command line. The virtual machine is running Linux and the terminal is running Bash. If you are unfamiliar with using the Linux command line, try this tutorial: Linux Tutorial for Beginners, especially Tutorial One and Two. So, to compile your first Java program just type:


The compile should only take a second or two. Then to run the program type:

java HelloWorld

Your reward is the text “Hello, World” being displayed in the terminal. Congratulations!


What did I just do?

So let’s take a moment to look at what just happened. First the source code. The file does three things. 1) It declares a class called HelloWorld. 2) It defines a method (a function) in the HelloWorld class called main. 3) The main() method calls System.out.println to output some text.

In Java, and in all object orientated programming languages, a class defines an object. An object is a self contained item that interacts with other objects. In Android such object would include elements in the UI, a network connection, some location data, and so on.

Each Java program must define a method called main in at least one class. It is the entry point, where the program starts executing. In the simple example above the main() method has just one line of code, a call to System.out.println to output “Hello, World”. println() is a method that belongs to the PrintStream class and is included as part of the System class. Oracle has lots of information about the System class and the PrintStream class.

To compile and run the program you first called javac and then java. The first is the Java compiler, hence the letter ‘c’ at the end, and the second is the Java virtual machine. Java is architecture-independent which means that a .java file isn’t compiled for a specific processor on a specific OS, like Windows on an Intel x86 chip, or Android on an ARM Cortex-A processor, but rather it is turned into Java bytecode. The job of the Java virtual machine is to run that bytecode on the specific platform.


When writing computer programs you will need to store some data for temporary use. For example in an Android game you will want to store the score of the current player. These bits of data are stored in variables – a box in which you can put some data and then come back later a retrieve it. Since data comes in different forms a variable needs to be defined with a type, which tells Java what is being stored. Some of Java’s primitive data types include int (for integer), double (for double precision floating point number), and boolean (for a true/false value).

Here is a simple program which sets the value of a variable, prints out the value to the console, changes the variable and then prints it out again:

public class VariableTest {
    public static void main(String[] args) {
        int i = 1;

        System.out.println("The value of i is: " + i);
        i = i + 24;
        System.out.println("The value of i is now: " + i);

Save the file as “”. To compile it type: javac, and to run it use: java VariableTest. The output of the program will be:

The value of i is: 1
The value of i is now: 25

As you can see the program defines a variable called “i” and gives it an initial value of 1. The value of “i” is printed to the console. Then i is set to the new value of i + 24, or 1 + 24, which is 25. The new value is then printed out.

Try modifying the program to use a “double” rather than an “int”. Set “i” to something like 1.3 and increase its value by another decimal number like 24.9.

If you take a look at the println() method you will see an integer being added to a string: “The value of i is: ” + i. What actually happens here is that Java knows that the first part of the expression is a string, so it generates the string value for i, in this case “1” and then concatenates it to the string giving: “The value of i is: 1″.


Strings are an important part of any programming language including Java. Unlike int or boolean, a string isn’t a primitive type it is a class. When you create a string variable you are really creating a String object (notice the capital letter S). As an object it has certain properties like its value (the string itself) and its length. Strings can be manipulated in lots of different ways, including being dissected, concatenated, compared, and searched.

Here is an example program that performs a few simple operations on a String:

public class PlayingWithStrings {
    public static void main(String[] args) {

        String hello = "Hello, World";

        // Add an ! to the end
        hello = hello + "!";

        // Extract the word "Hello" from the String
        // i.e. starting at the beginning (0) for 5 characters
        String justHello = hello.substring(0,5);

        // Add some trailing spaces and then remove them with trim()
        hello = hello + "     ";
        hello = hello.trim();

        // Now output the string all in UPPERCASE and lowercase

Save it as Compile it and run it using javac and java as shown previously.

This is a special method called a constructor. The constructor is called only once, at the moment that the object is created.

The first part of the program creates a String object called “hello” and gives it a value of “Hello, World”. Although this make look similar to how you declare and assign an integer or another primitive type, actually there is a lot more going on here. Java allows simple operators like = and + to be assigned simple tasks. So really String hello = “Hello, World”; is actually some like String hello = new String(“Hello, World”);, in other words, create a new object of type String and pass in the value “Hello, World” to the constructor. But we will talk more about that in the Objects section below.

The next part shows how you can concatenate strings, in this case an exclamation point is added to the end of the string. Since String is an object it can have methods. String.substring() is a method which returns part of a string. In this case the first 5 characters. String.trim() is another method which removes leading and trailing spaces. The last part of the program demonstrates the String.toUpperCase() and String.toLowerCase() methods.

The output from the program will be:

Hello, World
Hello, World!
hello, world!

You can find out more about the String object in Oracle’s String tutorial and from the Java String documentation.


If there is one thing a computer is good at, it is doing repetitive tasks. To perform a repetitive task in a programming language you use a construct called a loop – something that loops around again and again.

Java has three types of simple loop: the for loop, the while loop, and the do while loop. Each loop type follows the same basic idea, you need to repeat something over and over again until a certain condition is met.

Here is an example which shows how to print out the numbers 1 to 10, 11 to 20, and 21 to 30, using the three different types of loop:

public class Loops {
    public static void main(String[] args) {

        // For loop
        for(int i=1; i<=10; i++) {
            System.out.println("i is: " + i);

        // While Loop
        int j = 11;
        while(j<=20) {
            System.out.println("j is: " + j);

        // Do While Loop
        int x = 21;
        do {
            System.out.println("x is: " + x);
        } while (x <=30);

Create a file called with the code from above, then compile it and run as shown previously.


The for loop as three parts. First the initialization (int i=1), which is executed only once. In the example above the initialization is used to declare an integer i and set its value to 1. Then comes the test expression (i<=10). This expression will be tested every time the loop executes. If the result of the test is true then the loop will go around again. In this example the test is to check that i is still less than or equal to 10. After each iteration the third section, the iterator, will be executed. In this example it increases the value of i by one. Note that i = i + 1 is the same as i++.

The while loop is similar to the for loop, except it doesn’t contain the initialization phase and the iterator phase. That means that the initialization needs to be done separately, hence the declaration int j = 11;. The iterator also needs to be coded separately. In our example it is the line j++ which is found inside the loop after the println().

A do… while loop is very similar to a while loop with one big difference, the test to see if the loop should continue is at the end of the loop and not at the start. This means that a do… while is guaranteed to execute at least once, but a while loop doesn’t even need to execute at all, if the conditions aren’t met on the entrance into the loop.

Like the while loop, the initialization needs to happen outside the loop, in this case: int x = 21; and the iterator occurs inside the loop: x++. When x goes over 30 the loop will stop.


As I mentioned before, Java is what is known as an object-orientated (OO) programming language and to really succeed in Java programming and Android programming it is important to understand OO concepts.

At its simplest level an object is a set of methods (functions) that work on a data set. The data and the methods belong to the object, and work for the object.

Here is the source code for a very simple program which creates a counter object:

public class Counter {

    int count;

    public Counter() {
        count = 0;

    public void Increment() {

    public int GetCount() {
        return count;

    public static void main(String[] args) {
        Counter myCounter = new Counter();

        System.out.println("mycounter is " + myCounter.GetCount());
        System.out.println("mycounter is " + myCounter.GetCount());

The Counter object has one piece of data, the integer variable count and three methods (other than main): Counter(), Increment(), and GetCount(). Leaving the first method for the moment, you can see that Increment() and GetCount() are very simple. The first adds one to the internal variable count and the second returns the value of count.

Until now all the methods we have declared started with public void but if you notice the GetCount() method starts with public int. We will talk more about public in a moment, but the difference between void and int is this: void declares that the method doesn’t return anything, there will be no result coming back out of the method. But int tells us that the method will return a number, specifically an integer. You can actually create methods that will return all kinds of data, including objects.

Notice that the first method has the same name as the class itself, i.e. Counter(), and it doesn’t have a return type (not even void). This is a special method called a constructor. The constructor is called only once, at the moment that the object is created. It is used to initialize the object with default values and perform any other necessary initialization tasks. In this example it just sets count to zero.


The great thing about classes is that you can create a general class for an abstract idea and then create specific classes which are derived from the original class. For example, you can create a class called Animal and then derive a new class from it for a specific animal, say an Elk.

Here is an example, I will expand on what is happening here in a moment… You are going to need to create two files for this example, and Here is

public class Animal {
    int NumberOfLegs;

    public Animal(int n) {
        NumberOfLegs = n;

    public int GetNumLegs() {
        return NumberOfLegs;

And here is

public class Elk extends Animal {
    int lengthOfAntlers;

    public Elk(int l) {
        lengthOfAntlers = l;

    public int GetAntlerLength() {
        return lengthOfAntlers;

     public static void main(String[] args) {
        Elk myElk = new Elk(30);

        System.out.println("Antler: " + myElk.GetAntlerLength());
        System.out.println("Legs: " + myElk.GetNumLegs());

To compile the program just type:


The Animal class is what is known as a super class, while the derived class Elk is known as a sub-class, because hierarchically it is below the Animal class. When a class is extended (i.e. you create a sub-class) the new class takes on the data and methods of the super class. That is why the program is able to call myElk.GetNumLegs() even though it is part of the Animal class. The new Elk class has two variables: NumberOfLegs and lengthOfAntlers. It also has two methods: GetAntlerLength and GetNumLegs. If we created another sub-class, say Sheep, it would inherit the NumberOfLegs variable and the GetNumLegs method.

When designing objects you will discover that you want some methods to be exposed to the rest of the program, so that they can be called. But other methods you might want to keep private, so that only the object itself has access to it. This is where that word public comes into play. We have been declaring everything as public which means the method can be called from anywhere else in the code. However you can declare methods as private or protected, which will limit the access to those methods. The same access rules can also be applied to the object’s variables. A deeper discussion is beyond the scope of this tutorial, but if you would like some more information then you should read Controlling Access to Members of a Class and Declaring Member Variables from Oracle’s Java documentation.

One other thing worth mentioning is how the constructors work. The Elk() constructor initializes the lengthOfAntlers variable, in this case to 30, the number passed in when the object was created. But before that, it calls the constructor of the super class (i.e. Animal() ) using the special Java notation super.

There is a lot more that can be said about object-orientated programming (OOP), but this should be enough to give you a taste and get you started.

Wrap up

There are lots of online tutorials for learning more about Java. Here are a few from Oracle:

  • Getting Started — An introduction to Java technology and lessons on installing Java development software and using it to create a simple program.
  • Learning the Java Language — Lessons describing the essential concepts and features of the Java Programming Language.
  • Essential Java Classes — Lessons on exceptions, basic input/output, concurrency, regular expressions, and the platform environment.

You might also want to look at the following tutorials:

For those of you who would like an eBook or a printed book on Java programming then you might want to consider the following:

Also, good books on Android programming include:

Android Developer Newsletter

Do you want to know more? Subscribe to our Android Developer Newsletter. Just type in your email address below to get all the top developer news, tips & links once a week in your inbox:

PS. No spam, ever. Your email address will only ever be used for Android Dev Weekly.
ePad 7 Android 4.0 ICS
$162 $100 FREE SHIPPING 

10" Android 4.2 1.2GHz Tablet PC