Category Archives: Android

Android related articles and code demos.

Confusing Terms While Developing for Android

MANIFEST
The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app’s code. [5]

DALVIK
Dalvik is the virtual machine that is used by Android. It is generally thought of as a java virtual machine, although this is not precisely correct. It uses an object model that is identical to java, and it’s memory model is also nearly equivalent. But the dalvik VM is a register based VM, as opposed to java VMs, which are stack based.

Accordingly, it uses a completely different bytecode than java. However, the Android SDK includes the dex tool to translate java bytecode to dalvik bytecode, which is why you are able to write Android applications in java.[3]

rVSX8

DALVIK CACHE
When you install an application on Android, it performs some modifications and optimizations on that application’s dex file (the file that contains all the dalvik bytecode for the application). It then caches the resulting odex (optimized dex) file in the /data/dalvik-cache directory, so that it doesn’t have to perform the optimization process every time it loads an application.  So the “/data/dalvik-cache” directory is the DALVIK CACHE[3]

ART
ART is an application runtime environment used by the Android mobile operating system. ART replaces Dalvik, which is the process virtual machine originally used by Android, and performs transformation of the application’s bytecode into native instructions that are later executed by the device’s runtime environment.

Unlike Dalvik, which since Android 2.2 “Froyo” uses just-in-time (JIT) compilation to compile the bytecode every time an application is launched, ART introduces use of ahead-of-time (AOT) compilation by performing it upon the installation of an application. By reducing the overall amount of compilation that needs to be performed across the operation of an application, a mobile device’s processor usage is reduced and battery runtime is improved. At the same time, ART brings improvements in performance, garbage collection, applications debugging and profiling.[4]

AOT
ART introduces ahead-of-time (AOT) compilation, which can improve app performance. ART also has tighter install-time verification than Dalvik.

At install time, ART compiles apps using the on-device dex2oat tool. This utility accepts DEX files as input and generates a compiled app executable for the target device. The utility should be able to compile all valid DEX files without difficulty. However, some post-processing tools produce invalid files that may be tolerated by Dalvik but cannot be compiled by ART.[2]

Gradle
Gradle is a project automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the more traditional XML form of declaring the project configuration.

ANT
Apache ant is a generic build tool. The name ANT stands abbreviated for ‘Another Neat Tool’. This tool is similar to the ‘Make’ utility in UNIX but is implemented using Java. It is primarily used for building the binaries of a java based source code and deploying the generated binary to an application server which is predefined. It can also be used to generate javadocs for a code base and to execute the unit test suite for the whole codebase. Ant in collaboration with JUNIT helps developer to follow the test driven development approach.

Ant requires Java compiler to be installed having the environment variable JAVA_HOME set with its adequate value. Ant uses an XML file to define the build procedure. The default name of this file is build.xml. Some developers also use a properties file namely build.properties to define some properties e.g. the build version number and other environmental parameters which are required to change from time to time based on the need[1].

MAVEN
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.
This article will be updated periodically. And please feel free to comment the words you like to get some explanation so I can update this article with them.

Jenkins
Jenkins is not directly related to Android. Still as someone asked its explanation I am sharing a small description I found on the internet. Jenkins is an open source continuous integration tool written in Java. The project was forked from Hudson after a dispute with Oracle. Jenkins provides continuous integration services for software development. It is a server-based system running in a servlet container such as Apache Tomcat.

Reference
[1] http://mrbool.com/apache-ant-java-automating-your-build-process/29531#ixzz3DMUjg88b
[2]https://source.android.com/devices/tech/dalvik/art.html
[3]http://stackoverflow.com/questions/7541281/what-is-dalvik-and-dalvik-cache
[4]http://en.wikipedia.org/wiki/Android_Runtime
[5]http://developer.android.com/guide/topics/manifest/manifest-intro.html

My Life with Google Play Store

Hi Guys, this time I am back with some experience to share. Due to many requests I got from my developer community fans, I have decided to share my Google Play Store Experience…!

Google_Play_Games

As you know Google Play store is the Official Android App Store, where almost all the android users get their apps from.

So in this article I’ll write some points, in the forms of tips, based on my 2 years of experience with Google Play Store, where I have published more than 36 apps, with total of more than 1 Million User Base(apps downloaded more than 1 000 000 times), lost 7 apps, lost 2 of my play store accounts and running my 3rd account.

Hope the qualifications in the above paragraph will urge you to read the article 😉

Good to Know
Creating a Google Play Store account costs you one time payment of 25 USD.
You can publish unlimited apps till 3 of your apps get suspended for violating their privacy policy and BLA BLA things…!
After market get suspended, they will not allow you to start a Google Play app store from the same account. So you have to start another Account.
😀

Tip 1
When you are planning to publish an app for money(Selling an app for money in app store), unless you have a good client info tracking system don’t do it. Because one guy can buy your app, create backup which gives him the apk of your app, which he will publish in the Open Internet for everyone to get it and have it for Free. So always build free apps with Ads, so whatever happens you will still get money out of the ads.

Tip 2
Before you name your app please check if the word you are going to use in your app is allowed in United States of America. Because USA is the number one android market place with more than 75% of the app downloads happen, also they ban apps which has certain words or names. For example if ‘country x’ is in their black list, they block the apps with ‘country x’ in their names. Which will end up in a big loss to your app and expectations.

Tip 3
One of the easiest way to gain lots of download is to use a brand name(example: batman, Spiderman, Google), or a similar name to a popular app that’s available on that season(example: flappy bird, flappy tin man). But be warned that your app will be suspended sooner or later, even without giving you a warning. And there is no way of getting the app online.
Best tip on this will be use the brand name for sometime and replace them with your own after getting enough rating so your app is visible in the search(Not Recommended, you don’t know when they will suspend the app).

Tip 4
Add some relevant and popular tags in the description before publishing the app, it generates some traffic for your sites.
example: And have fun sharing with your friends on social network. #facebook #instagram

Tip 5
When developing an app always try to set the maximum possible min SDK value, so you will get a wide audience which results in increased download rate. Also if possible take screen shots from 7 inch and 10 inch tablets screen shots of your app and add them(There is a specific section for it in the app publication form), so that will enable the app to be downloaded by the tab owners too.  Don’t care about the ugly interface when installed to a tab(if it is not designed for tabs ), even you can take a normal phone screen shot and create a tablet sized image with image editing tools.
😀

Tip 6
Whenever you publish an app try to get it some 5 star rating with your friend’s help, people think that we are cheating, but the truth is you are actually pushing your app in to the Google play store search a bit so that it gets visible to all the users, so then it is up to the true down loaders to give the real rating for your app.(There are some of the Marketing Strategies I tried and succeeded)
😀

You must understand, publishing apps in the app store is my hobby and not my profession, and I have lots of fun with the play store.

I have written all that came to my mind, this article will be constantly updated.
So tune in…
🙂

 

 

Google Glass Development Kit Sneak Peek Revision 2 – List of Some API Changes

I came across lots of problems when the glass updated to XE12, long ago. Today I found out this article which I thought I would like to share with you all.

My Glass was automatically updated with the monthly update XE12. This update included a new version of GDK implementation, known as Sneak Peek Rev. 2.

Since the update, I could not run any of my GDK sample apps. I was getting errors like: java.lang.NoSuchMethodError: com.google.android.glass.timeline.TimelineManager.getLiveCard.

As it turned out, this new GDK revision included some non-backward compatible API changes. Clearly, names like “Sneak Peak” or “Preview” edition imply they are not stable releases, and APIs can change any time. But, I was caught a bit off-guard, and a bit disappointed since it happened “without warnings”. (Or, maybe there was a pre-announcement, and I may have missed it because I’m off-line most of the time these days.) I mentioned the importance of “backward compatibility” in software engineering a few times before. Even more importantly, I believe that software engineers should strive for “forward compatibility”. This is a difficult goal to attain because, in many cases, developers do not know what product features they will need to support in the future. In most organizations, they come down from “PM’s” or people from “higher up”. Nonetheless, I think it is possible, and it is worth pursuing.

Anyways, I went through all my sample apps on GDK Demo and updated the code based on the new API. I’ll include the list of API changes here. This is only a partial list since the GDK Demo apps use only a subset of the GDK APIs.

First, you’ll need to update your GDK using Android SDK Manager. Since the original GDK release about a month ago, there seems to have been no other Android updates. When I opened the SDK Manager last night, it found only one update, GDK rev. 2. You can copy the updated gdk.jar file into your project dir and include it in your build path, or you can just set your compileSdkVersion to a GDK-specific string. I personally prefer the first approach because there are some benefits of using a higher version for compileSdkVersion than that of targetSdkVersion (which should be 15 at this point). If you plan to do any “cross-platform” development (e.g., your app targeting both Android phones and Google Glass), then you probably have no choice but to use the Jar file.

So, here’s the list of API changes in GDK (as relevant to the currently “released” GDK Demo apps).

  • TimelineManager: Method name change from getLiveCard(cardId) to createLiveCard(cardTag). (I’m only presuming that these are the same method, and the API change entails only the name change.)
  • LiveCard: It appears that the method setNonSilent(boolean) has been removed. Instead, this “nonsllent” flag is set during publishing. The signature of the method publish() with setNonSilent(true) has been changed to publish(LiveCard.PublishMode.REVEAL). If you used setNonSilent(false) for your livecard, then you now need to call publish(LiveCard.PublishMode.SILENT) instead.
  • LiveCard.enableDirectRendering(boolean) has been changed to setDirectRenderingEnabled(boolean).
  • com.google.android.glass.media.Camera has been, it appears, renamed to CameraManager.
  • The surface rendering callback interface, LiveCardCallback seems to have been renamed as DirectRenderingCallback. My existing code just compiled fine (haven’t tried running them all though) after only changing the interface name.

That’s about it. Again, this is only a partial list of API changes in the new “Revision 2” version of GDK (as relevant to the “GDK Demo” sample Glassware). I haven’t done any comprehensive comparison of old vs. new GDK jar files or anything like that (which is probably easy to do). Google might have posted some kind of “release note” or “change log” at this point (which I haven’t seen yet though).

Meanwhile, I hope other GDK developers find my list useful, for now.

PS 1: BTW, interface name changes like LiveCardCallback -> DirectRenderingCallback possibly imply that there might be something coming in the future that are in some way equivalent/similar to LiveCard (maybe, DeadCard? :)). This is known as “breaking backward compatibility for forward compatibility”. We developers do this all the time, whether we realize it or not. We create, say, a class for certain purpose (with a certain name), and later realize that we have chosen too specific a name because the class can be more broadly applicable than initially planned.

Reference – http://blog.glassdiary.com/post/70419002255/google-glass-development-kit-sneak-peek-revision-2

Link to the GDK Release note – The GDK release note page.

Android Wear

Hi guys, this time I’ll write about the new Android Wear, which was announced on last week. So what is it all about?
Android wear, a new OS while already wearable devices are coming with Android as OSs?

Its a new approach by Google to bring a new concept by creating a new development area with targeting only wearable devices.

It’s not a completely new OS, its the same android but made specifically for wearable device software development.

‘Google Says that the Android Extends to Android Wear. Richer Experience for the Wearable devices’ –  Official Intro Video

So this time there are 2 types of designs unlike the galaxy gear and smart watch 1 and 2 you can see a circle one and a traditional square screen. As I have heard the square one is going to be manufactured by LG, which has less spec and smaller price tag, where the circle one will be made by Motorola with high specs.

For developers, Android wear SDK developer preview has been released, so you guys can download and try it out. Which will be a great experience in the future when the device is out in the market.

So with the help of the official article I managed to find out that you can do the below  shown basic functionality.

functionalities

It does not mean that you have to learn anything new you also can use the old APIs

‘You can also trigger your notifications contextually using existing Android APIs. For example, use geofences to provide glance able information to your users when they are at home, or use the activity detection APIs to send messages to your users’ wrists while they are bicycling.’

So what are you waiting for register for developer preview, download the sdk and start developing.

🙂

References : Android Wear | Android Developers

Lets try Android Game Development with AndEngine

Hi Guys, this time I am back with some Android Game Development. I got this idea after, the popular game Flappy Bird. Hope all may have tried that game…!
Ok, so I wanted to develop a game and I did some researches and found out that there are a lot of Game engines out there.  Some of them are COCOS2D, AndEngine, libGDX and many others. In this article I’ll guild you using AndEngine which is a bit easier one. In future I’ll write on libGDX.

Assumption : I assume that you guys know how to install eclipse development environment, configure java path and install Android plugin to eclipse. This post does not cover all those basic steps.

Advise : As this is a kind of a crash course, its advisable to create files the same name as I use(But it is not mandatory).

Expected Outcome : You will be able to create some lines using the AndEngine

Step 1
Download the Source(library) for the AndEngine using this link and extract
https://github.com/nicolasgramlich/AndEngine

Step 2
Create a new project and when creating select ‘Android Project from Existing Code’ and in it select the folder that we extracted in the Step1.
existing code

This is a library project. Actually this library is the ANDENGINE.
libraryproject

You can check it by right clicking on the project we created now and going to the Android tab. You can see the ‘Is Library’ check box ticked.

Step 3
Now create a new Android project and un tick the create activity. Because we are going to create AndEngine activity using the library project we created above.
createactivity

Step 4
Now you have a project with empty src folder. Right click on that folder and create a new package when naming the package use the package name available in that project ManifestFile
packagename

In my case package name is ‘”com.batz.andengsample”‘

Step 4
Now in side the empty package Download or copy the code and create LineEample.java activity using this LineExample Source Code.

You will get some errors, but don’t worry we will fix it in the next step.

Step 5
So now in your project, right click and go to Android tab and there in the below section(library section), click on the add button and select the AndEngine project and press ok. And then press Apply.
add library

Now all the errors may have gone. Some times you will have errors on the package name, if you have used your own name. So for that, click on the package name that shows as error, click ctrl key +1 key , which will bring suggestion to create a package name according to yours, and click on it to create it. And hopefully all the bugs will be fixed.

Step 6
Before going for the app launch, we have to do one more important thing, we have to specify the activity we created now in the manifest file as a launcher

So go to the manifest file and add these lines between the application tags

         <activity
android:name=”.LineExample”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
manifest

LineExample is the name I gave for the activity we created, so in your one don’t forget to change that

Step 7
Now you are ready to run the app. So while you are in the the activity try running the app. it should bring a screen where you will see lots of random lines.

Step 8(For people getting error saying cannot find andengine.apk)
For some people the AndEngine folder is not getting added as library on the time of building the app. So at that point what you can do is copy the andengine.jar file from the AndEngine project libs folder and copy it into your projects’s libs folder. And right click on the newly added andengine.jar file and click on ‘Add to Build Path’ option. This is how the project structure looks after I added the jar to my project from the AndEngine project in the Step8

projectstructure

AndEngine Resources : http://www.andengine.org/

For people who got more time , for people who needs more detailed instruction on the same project guild please watch this tutorial video
Development Reference : http://www.youtube.com/watch?v=Q0kjiIH6u-M

Thank You
Happy Coding…!

-Batz-

What comes with the new Google GLASS Development Kit?

The GDK is an Android SDK add-on that contains APIs for Glass-specific features.
sdk-gdk

Unlike the Mirror API, Glassware built with the GDK runs on Glass itself, allowing access to low-level hardware features.

At the time of writing this article Sample GDK has been released out introducing ways to develop native android apps for Google Glass.

gdk-glassware-android

So what does the new GDK brings

1. A new platform for you to develop your GLASS apps so it will have special libraries needed to for the Google GLASS. Not all are available yet, you have to wait for the final version to come.

2.Touch Gestures – Accessing raw data from the Glass touchpad is possible with the Android SDK. However, the GDK provides a gesture detector designed for the Glass touchpad that automatically detects common gestures on Glass, including tapping, swiping, and scrolling. Click Here for detailed info on developing

3.Voice Input – Voice is an integral part in a hands-free experience for users. Glass lets you declare voice triggers to launch your Glassware from the ok glass voice menu. Click Here for detailed info on developing

4.Location and Sensors – You access location and sensor data using the standard Android platform APIs. You have to access the paired device for location and there is another way of gettin location without the help of paired device. It is taken based on the Wifi hotspot, but it wont be accurate as much as the location taken fron the paired device’s gps. Click Here for detailed info on developing

5.Camera – You can use the Glass camera to capture images and video and to also display the camera’s preview stream for a variety of different use cases. Click Here for detailed info on developing

Reference : Site Name – Glass Development KIT, Url – https://developers.google.com/glass/develop/gdk/index, Date 5th December 2013, Time – 12.13pm (GMT +5.30)

Google Glass – Adding your Own Voice Commands to Your Apps

Hey guys with the introduction of the Glass development Sneak Peek, I found the way to add your own voice command to trigger your app. This is for native Android Apps.

What you have to do is,

Step 1
inside the manifest file add these tags under the service which you wanted to trigger on your voice command.

<intent-filter>
<action android:name=”com.google.android.glass.action.VOICE_TRIGGER” />
</intent-filter>
<meta-data
android:name=”com.google.android.glass.VoiceTrigger”
android:resource=”@xml/voice_trigger_start” />

Step 2And you have to create a folder called xml inside res and add a xml file named as “voice_trigger_start.xml”

Step 3
Inside that add these lines

<?xml version=”1.0″ encoding=”utf-8″?>

<trigger keyword=”@string/its_me_amalan” />

Step 4
Open the values folder inside res folder and edit strings.xml, so it will look like this

<resources>
<string name=”app_name”>Amalan</string>
<string name=”its_me_amalan”>Hello Amalan</string>
<string name=”stop”>Stop</string>
</resources>

Now install the app into the google glass and say
OK GLASS Hello Amalan
And the app opens

I have used my name 😉 but you can try lots of other words.

Please install the latest  Glass Development KIT and tryout the samples, you can get more out of it 🙂

Get the Source here
gitHub-download-button

 

Google Glass and It’s Battery Consumption

Ok, developing apps and glassware for Google Glass seems to be not a big deal……!
But there are some hidden issues we have to take care of…!

GoogleGlass_1

1st one is Battery and the 2nd one is Performance…!

Even though the Google said the Battery will last for 1 Day, I could not experience the glass battery as long as that, unless it was left to sleep. When the Battery was full, I started taking a video, I got warning in 20 minutes saying battery is low, that’s it, I have to stop taking video and shutdown the glass. Here is the Video Taken.

So you must have understood, how poor the battery life is in Google Glass. So running a native Android is really a battery draining factor, specially pairing to phone through Bluetooth. And if you are using any sensors in the glass then that will cause heavy battery usage.

Alternatively we can do something like, keeping down the brightness of the display, and put the glass to sleep at most of the time(When app is idle). Avoid doing heavy process in the glass by sending the data to a server and process it and get the result.

I have read some people’s review say, using Glassware can solve the battery problem. Yes, as it is a plain html card which does not java script it won’t drain much battery.

But anyway the cards are shown in web browser objects. Smart phone users know the battery drain very much when they use web browser. So If the glassware results are going to be  shown in a series of web browser object which is called time line won’t it be draining battery very much? This point is just a conceptual thinking of mine.

Even though we have discussed only some facts about battery, there are more hidden battery factors too. But some leaked patent doc shows possible 2 side battery increasing the battery capacity by double.

One of my friends suggested a tip and it is using external battery w/USB
Here is the picture of it. You can try this too if you want more battery power. Further he mentioned that it lasts for the whole day. If you like follow him on twitter for more tips
BVfIq94IEAAZP3B.jpg large

That’s all for today, catch you guys soon with more on Google Glass…!

Google Glass Consumer Vesion Sneak Peek

Screen Shot 2013-09-15 at 7.22.51 PM

So here we can see that the google glass can be rotated up/down and left/right, where in Explorer Edition only left/right is possible. This is one of the most wanted features by the glass users.

Screen Shot 2013-09-15 at 7.21.52 PM

So in the above picture we can see that the battery will be placed on both sides for more battery, where in Explorer edition we got only battery on right side. This really increases the usage time of glass.

Screen Shot 2013-09-15 at 7.21.42 PM

In this picture you can see the glass can be moved forward and backward to adjust the view.

So with some of these features we can predict that, a adjustable user friendly device,
a device with more battery for extended usage and heavy usage.
With all these features we can we can hopefully fix a custom glass as wanted.

These are just the things known for now, but there are still, 7 or eight pages to be relieved.
So keep you eyes open , ill be updating more soon.

Image Resource  from +Isabelle Olsson(Googler)‘s Gplus post, about recent patent on Google Glass (published on September 12th).

Google Glass Vignettes

Vignettes is a new feature added to Google Glass with XE9 update, which out puts the photo taken with the actual view in the Google glass screen. So I have taken some Vignettes which shows the Glass initial view and some pages in the Settings.
The last one is a google hangout call notification.

See for instruction on how to take a Vignette through Glass

20130910_130122_217_x
20130910_125335_521_x  20130910_125400_989_x  20130910_125411_746_x  20130910_125425_065_x  20130910_125435_700_x  20130910_125445_357_x

20130910_125456_088_x

20130910_125505_097_x

To create a Vignette, simply press the camera button and single tap on the photo preview shown soon after it and it will show you the option to create Vignette. That’s it you Vignette will be ready to share.