Droidin' out tips and tricks from an android developer

31May/111

android and JDK compliance – how to fix @override errors

Posted by noslen

 

 

From time to time when working with other people's projects I run into build errors that are caused by the @override annotation. It took me a while to understand why that was happening as I was usually able to solve it by simply deleting the @override annotation or adding it where needed.

an example of an error caused by @override

Turns out the problem is because of of a mismatch in the JDK different developers are using.

Starting in Java 6 the @override annotation no longer applies to interface methods. So most methods derived from an interface no longer need them. They are however needed with Java 5.  The problem arises if a dev with Java 5 creates an android project, By default the project will get set with whatever JDK compliance is valid in their environment, in this  Java 1.5. If a developer with java 6 opens the same project all  @override annotations will be flagged as errors when appearing above interface methods.

Thankfully, this is easy to fix.

You simply need to go to your android project properties, choose the java compiler and select the appropriate JDK compliance level for your environment.

Project Properties > Java Compiler

Click enable project specific settings to be able to select the appropriate JDK version to use.

Don't know which hava version you have? No problem. Simply type java -version in your command line to get that info. It will look like below

how to check your jdk version

Don't want to have to do this every time you and another developer have mismatching JDKs? You can configure it as a default on your workspace.

From the same Java Compiler properties window, click "Configure Workspace Settings"

That will bring you to the window below where you can choose your default Compiler compliance level for your JDK Compliance.

configure your default workspace settings

As per usual i'd like to thank the fine folks @ stackoverflow for their help.

Filed under: android 1 Comment
22May/110

Android units – pixels, density, dpi, dip, dp, dps, sp, sip | Edwin Evans

Posted by noslen

A bit more on dealing with android units.

Android units – pixels, density, dpi, dip, dp, dps, sp, sip | Edwin Evans.

 

 

Filed under: android No Comments
15May/110

adb command line: How to launch an app from adb

Posted by noslen

If you ever need to launch an app from the adb command line here's how.

First, if you haven't added the platform tools to you %PATH% environment you should. It's a great time saving shortcut.

Ok now that you're cool like us on to the adb command:

You need to use the am command which is an adb shell command. adb has its own set of commands, adb shell has its own other set.

So what does the syntax for the am command look like? First i'll show you the command and then i'll explain it.

Ok so there it is. adb shell am start -a android.intent.action.MAIN -n com.rga.sony/.ZeusMain

Here is also a pretty great explanation:

http://www.anddev.org/using_the_am-tool_start_activities-intens_from_a_shell-t368.html

 

Filed under: android, general No Comments
11May/110

Funny things you find

Posted by noslen

The SensorManages to be funny.

Filed under: android, funny No Comments
6May/112

Android: How to fix Seekbar bar thumb centering issues.

Posted by noslen

If you ever need to change the height of your Seekbar you may find that the thumb is not centering properly.

The fix for this is actually pretty simple. It just took me a while to find, so i'm posting this in the hopes of helping fellow developers cut down on their search time.

After trying things like gravity and margins and such with no success, i wondered well how the heck does android do it anyway?
That led me to seeing how they define their default seekbar style.

        false
        @android:drawable/progress_horizontal
        @android:drawable/progress_horizontal
        20dip
        20dip
        @android:drawable/seek_thumb
        8dip
        true

Which i then compared to mine.

		fill_parent
		60dp
		@drawable/slider_thumb
		@drawable/seekbar

What immediately caught my eye was the minHeight and maxHeight attributes. It's possible that when this widget is being laid out android takes these values into account so I tried it.

		fill_parent
		60dp
                60dp
                60dp
		@drawable/slider_thumb
		@drawable/seekbar

Lo and behold it worked!
centered

So what's the answer?

If you need to adjust the height of your seekbar make sure you define the minHeight and maxHeight attributes or your Seekbar because android takes them into account when placing the thumb.

Filed under: android, general 2 Comments
2May/110

Google Translate “Conversation Mode” in action

Posted by noslen

Google translate for Android is simply AWESOME.

Best.App.Ever

Filed under: android, news No Comments
27Apr/110

Warning! EasyTether will break ADB

Posted by noslen

I recently tried to use EasyTether on my development machine with disastrous results!

It didn't really work well and when I went back to developing adb could not see my devices anymore!

the adb devices command would display nothing!

After a few hours of searching around I came across this stackoverflow post that helped me fix my problem.

Here's the link: http://stackoverflow.com/questions/4435031/adb-devices-list-empty-snow-leopard

Here's the things that I did to troubleshoot:

1. rebooted the phone and machine

2. removed the network connection created by easytether

3. checked the usb ports and cable

4. made sure USB debugging was checked off.

5. unplugged and plugged in several times

6. repeated steps 4 and 5 on other devices.

Once I had gotten no results I knew something else was going on.

Some sleuthing yielded the thread on stackoverflow. Did I mention I love stackoverflow?

 

Filed under: android No Comments
22Apr/110

Android will dominate the market by 2015

Posted by noslen

In the lead Android has little to worry about as it will be nearing a 40% market share over the course of this year. An increase in sales by 23.8% over each of the following four years will let it increase that even further to an estimated 45.4% in 2012 when Nokia is supposed to make its first large-scale move with WP7 devices.

WP7 will go second by 2015, iOS and BlackBerry will lose ground - GSMArena.com news.

Filed under: android, news No Comments
21Apr/110

Game Programming Patterns – Object Pool

Posted by noslen

Improve performance and memory use by reusing objects from a fixed pool instead of allocating and freeing them individually.

While this is a game programming concept, it's very useful for things like particle systems.

via Game Programming Patterns / Optimizing Patterns / Object Pool.

Filed under: android No Comments
21Apr/110

Oh, Apple! When Will You Learn? | xda-developers

Posted by noslen

In the most recent episode, Apple believes that Samsung’s Touchwiz UI is a direct copy of the UI present in the iPhone/iPod/iPad. This will likely be an interesting debate in a courtroom when Apple tries to demonstrate that they invented one of the following concepts:

Clicking on an icon to open an app;

Touchscreen;

Icons;

Alignment in a square array;

Swipe motion to change screens;

via Oh, Apple! When Will You Learn? | xda-developers.

Filed under: android, news No Comments