Tag Archives: Android

Facebook Mobile HACK – Tel Aviv

Once in while I have a chance to attend an event that actually leaves an impression, “Facebook Mobile Hack” was one of those.

The event lasted for 12 hours ! it had technical lectures from Facebook R&D and what I think was the cream the la creme, the hackaton.

If you had a chance to read Mark’s manifest then you understand that intense hack days like these are rooted deep in the Facebook culture and all I can say that it was magnificent.

Beer in one end, coffee on the other I sat in one of the corners of the hanger and started coding for about 5 hours, sitting on my chair and feeling how the adrenaline is pumping. At the end of the hackaton all of the contenders went to stage, pitched the idea to all of us and to the panel of judges (Yossi Vardi,  influential VCs, Angels and techies).

The winner of the event was a cool app called Instapeace which connects FB and Instagram. Unfortunately I didn’t win, but you can see the end result on the Android Market – I Want To Buy

For those of you interested in the technical stuff you can download the presentations from here.


Leave a comment

Filed under Building

AOP on Android – Duplicate files at the same path inside the APK

This post won’t deal with Android/aop configuration, for more information on the subject  I would recommend reading this one.

I’ve been struggling all day to resolve an annoying issue I had with aspectJ, Android and Maven.

When compiling java class files to dex the dex compiler packs everything under the same file, classes.dex. During this process if for any reason you have files with the same name that exist under the same path then you’ll have the dreadful exception “Duplicate files at  the same path inside the APK”.

Whenever using the aspectj maven plugin a configuration file named builddef.lst is created and is placed in the project build output directory. It seems that this is the culprit for duplicate file exception. One way to solve it is to use argumentFileName parameter under the plugin configuration:

                <goal>compile</goal>    <!-- use this goal to weave all your main classes -->
        <argumentFileName>trace.lst</argumentFileName> <!-- Set the name here -->

The problem is the need to give a different name for each library that uses aop, annoying to the say the least.
If only we could remove the configuration file from the final jar/apk, guess what…you can. The jar plugin comes to the rescue:


We are excluding trace.lst and avoiding the problem from the start. Make sure to add this plugin under the build section of your pom file for each jar/apk that uses aop and you are done.

Leave a comment

Filed under Building

Android SDK under command line environment

I have a dedicated server as a build machine running Ubuntu server edition. I want to run my Android builds and for doing that I need the android SDK.

As you all know in order to download the various packages you need GUI interface, so how do you install them if you use CLI only.

Do the following:

  1.  Download the android SDK from http://developer.android.com/sdk/index.html
  2. tar xvzf <tgz file>
  3. Add to your path …/<android_dir>/tools
  4. run ‘android update sdk -u’ and everything will be downloaded to your computer.

Leave a comment

Filed under Building

Make your app social

Using a neat little feature you can make your app social using 5 lines of code.

The idea is to launch an intent of type ACTION_SEND which will pop up an Android dialog box for sharing. Every activity that binds itself to this activity will be displayed. Usually activities that have sharing capabilities (like Linkedin, Twitter and Facebook) will show up in that list.

Share using SEND_TO

Use the following code:

Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");

intent.putExtra(Intent.EXTRA_TEXT, "Description");
activity.startActivity(Intent.createChooser(intent, "Dialog caption"));

Ain’t that simple ?

In case you want specific activities to handle your request then make sure to change the type, usually most social apps will listen to text/plain.

Leave a comment

Filed under API

CouchPotato Me – New version

I’m happy to announce a new version of the CouchPotato Me app that supports Twitter.

In order to tweet automatically just make sure that ‘Post to Twitter’ is checked on settings or you can always tweet individual workouts from the history.

Go and grab it from the Market.

Leave a comment

Filed under CouchPotato App, Twitter for Android

Reduced size of Twitter for Android lib

One of the biggest problem with the previous implementation was that it used both Oauth and Twitter4J, the end result was a big APK file.

I’ve changed the code (you can download it from here) and removed Oauth, I’m using now Twitter4J version 2.2.2 which has built in support for OAuth,

In addition a new method was added which enables you to retrieve an initialized twitter object with the correct access token. See example:

Twitter twitter = TwitterUtils.getTwitterObject(activity, consumerKey, consumerSecret);
// Indicates that user was not authenticated
if (twitter == null) {
	Log.e(Constants.TAG, "User is not twitter authenticated");
	Toast toast = Toast.makeText(activity, "Please authenticate yourself first.", Toast.LENGTH_SHORT);
else {
	// User the twitter object to do your bidding.

Leave a comment

Filed under Twitter for Android

Twitter for Android

After searching for so long I still couldn’t find any decent library for Android that is as easy to use as the one supplied by Facebook, so I decided to create my own and publish it as open source. It’s still not complete and more work is needed to make it fully featured, but it is a good start. You can find it on google code.


Twitter for Android is based on Twitter4J, OAuth libraries, Facebook design and some code from Do it Yourself Android blog. I’ve used the FbDialog class from Facebook Android library and modified it to work with Twitter.

The basic flow :

  1. Retrieve the request token using OAuthRpovider.
  2. Load the response URL inside a Web View.
  3. User authorizes your app.
  4. Retrieve access token and store it in shared preferences.


mUseTwitter = (CheckBoxPreference) findPreference("use_twitter");
// In case user clicks on twitter authenticate it.
mUseTwitter.setOnPreferenceClickListener(new OnPreferenceClickListener() {
	public boolean onPreferenceClick(Preference preference) {
		if (mUseTwitter.isChecked()) {

			// Make sure to pass the consumer key and secret you got back from Twitter.
			// Use dialog listener to act uppon errors.
			TwitterAuthDialog dialog = new TwitterAuthDialog(activity, Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET, new TwitterDialogListener() {

				public void onComplete(Uri values) {}

				public void onTwitterkError(TwitterException e) {
					String error = e.getMessage();
					Log.e(Constants.TAG, error);
					// Uncheck the checkbox.


				public void onError(TwitterDialogError e) {
					String error = e.getMessage();
					Log.e(Constants.TAG, error);
					// Uncheck the checkbox.

				public void onCancel() {
					// Uncheck the checkbox.


			// Show the authentication dialog.

		return true;

The code demonstrates how to authenticate the user when he/she presses a Twitter checkbox in a preferences window. The most important line is #9 where you actually create the dialog box and pass the key and secret which are mandatory to the OAuth process. Whenever the user finishes the authentication appropriate events will be triggered.

Outstanding issues

  • Unfortunately unlike Facebook, Twitter does not give any indication that the user clicked cancel during the authentication process, therefore the dialog box will not automatically dismiss itself which might cause confusion for the user.
  • Size too big.


  1. Twitter4J
  2. Facebook SDK
  3.  Do it Yourself Android blog
  4. Download now the source code

1 Comment

Filed under Twitter for Android