Category Archives: Android/Java

Posts about Java and Android

iAndroidRemote – Control your Android phone using Apple Remote

Long time readers of my blog, would know that I hack around Arduino. Couple of days ago, I was playing around with Arduino while listening to music from my Android phone. I wanted to increase the volume of the song that was playing.

At that moment an idea struck me and I thought it would be cool if I can control the volume using some kind of remote. I opened my bag and found an old Apple remote.

Couple of hours later, I was continuing hacking around Arduino, listening to music from my Android phone, but now if I had to change the volume or change the track, I don’t have to reach for my phone, I can do it using my Apple remote itself ;)


If you want to know more about how I did it, or want to try it out yourself, then head over to the project page, where I describe the entire process including the schematics and the source code for both Arduino and Android that I am using.

Try it out and let me know how it works for you. Happy hacking ;)

Posted in Android/Java, Arduino | Tagged , , | 5 Comments

Sharing content in Android using ACTION_SEND Intent

Very often, you might want to enable the ability for users to share some content (either text, link or an image) from your Android app. Users can share the content using email, twitter, Facebook, sms or through numerous other ways.

The users might already have installed some custom apps for each one of the above service. So instead of coding all these again, it would be really nice (for both your users as well as for you as a developer) if you can invoke any one of these apps, where users want to share content from your app.

Sharing text

Android provides a built-in Intent called ACTION_SEND for this purpose. Using it in your app is very easy. All you have to do is to use the following couple of lines.

In my phone, it invokes the following dialog box listing the apps that have registered to get notification for this intent.


Sharing binary objects (Images, videos etc.)

In addition to supporting text, this intent also supports sharing images or any binary content. All you have to do is to set the appropriate mime type and then pass the binary data by calling the putExtra method.

Registering for the Intent

If you want your app to be listed when this Intent is called, then you have to add an intent filter in your manifest.xml file

android:mimeType specifies the mime type which you are interested in listening.

Happy sharing ;)

Posted in Android/Java | Tagged , , , | 58 Comments

FeedStats, my first Android app

Just a quick note to you let you guys, that I have just pushed my android app to the market. :)

It’s called FeedStats and it allows you to get the stats of a feedburner feed url and shows the data in a graphical format.

I created this app to demonstrate how we can draw graphs in android using JavaScript in a HTML page and then embedding it inside a webview.

If you have an android phone, then you can download it from the Android market, by searching using the term “FeedStats”. Try it out and let me know if you have any feedbacks/comments.

The entire source code of the app is available at my github account. Download and play around with it.

Posted in Android/Java | Tagged , , | 10 Comments

Making Arduino talk with Android using Amarino

Last week, I gave a talk + demo about using Amarino to make both Arduino and Android talk to each other in Bangalore Open source Hardware meetup

I have uploaded the slides which I used for the talk to my slideshare account and you can download it from there.

The slide also includes the schematic diagram for the circuit which I used for the demo. The source code that I used for the demo can be downloaded from the below links

Posted in Android/Java, Arduino, Events/Camps | Tagged , , , | 3 Comments

Adding additional account to Android phone and buying paid apps in India

After paid apps were introduced in Android market for Indian users, I wanted to buy a couple of them. But it took me a couple of days to do it, because of a variety of related and un-related issues. I thought of documenting it here, so that it would be useful for others who are facing the same problem.

The first issue that I faced was that, I have associated my phone with my Google App account and not a regular gmail account. Because of this, I was not able to use Google Checkout to buy paid apps. To fix this, I was supposed to add another Google account that has Google checkout enabled.

The second issue is that, there is some bug in android which doesn’t allow you to add additional accounts. The symptom of this bug is that you will get a error message which says “You don’t have a network connection”, even though you are connected through wifi or gprs. It took me a couple of days to figure out that it is a bug. Searching the internet revealed, that this bug is found across devices and across Android OS versions. I really wonder why Google has not fixed it yet.

Anyways, after searching sometime, I found out a relatively easy fix. You can try to add the account using the Youtube app. The following are the steps to do that.

  • Open up your Youtube app
  • Select menu –> My account and then click Add Account. Enter the new email address
  • Go back to your home screen and then select Menu -> Settings -> Accounts & sync
  • Set sync settings there and put in the password when prompted

Now you can go to the Market app and start buying paid apps. :)

Posted in Android/Java | Tagged , , , | 4 Comments

Generating graphs in Android

I wanted to visualize data using graphs in one of the Android app that I was developing and found that Android SDK don’t provide a good graphing API, which you can use out of the box.

You have to either using Canvas 2D graphics to draw your graphs from scratch or use some commercial components.

If you can assume that some form of Internet connection will be available then you can use Google Graphs API to get the graph and embed it in a webview control. But I didn’t wanted to make that assumption and so I started to search for a good graph component, which I can use in my app.

After some frustrated search attempts, I stumbled upon a wiki at rapid android, which explained, how you can use jQuery based JavaScript library flot to draw graphs for android. At first I dismissed it, since I didn’t wanted to assume that an active Internet connection would be available for my app. But after reading it for the second time, I realized that the graphs could be drawn using HTML and JavaScript files stored locally, without the need to be connected.

So I wrote a sample app to try it out and it really worked out great. I thought of posting the source code and a little writeup about it so that it would be useful for others as well.


So my goal was to create graphs in android using any JavaScript or HTML that are stored locally. The app and the graphs should work even if access to Internet is not available.


Flot is a jQuery based JavaScript library that was easy to use and created powerful and feature-rich graphs. The main advantage of flot is that it is completely compatible with the browser that is available in android.

Setting up webview

The first thing that we have to do is to setup webview, which will be rendering the HTML page, on which we will be drawing the graph. You can add the webview control to your android layout.xml file using the following code.

Once it is added to your layout.xml page, you can access it in your activity using the following code.