Blog Archives

Android Get Width And Height Of Image From Resource

In Android to get the width and height of an image from your res folder do the following: BitmapDrawable bd = (BitmapDrawable) this.getResources().getDrawable(R.drawable.icon); int height = bd.getBitmap().getHeight(); int width = bd.getBitmap().getWidth(); If you want the width and height depending the target

Posted in Android, Tips and Tricks Tagged with: , ,

Android Can’t Find File android_winusb.inf

The android_winusb.inf file is in a subfolder of the Android SDK directory, specifically: ..\android-sdk\extras\google\usb_driver\android_winusb.inf In older version of the sdk it was in ..\android-sdk\usb_driver\android_winusb.inf Depending on the installation and updates you might have both. The file in extras is the

Posted in Android, ErrorFix Tagged with: , ,

Windows 8 Android HTC Desire HD Developer

HTC Sync is not compatible with Windows 8 yet. This include not being able to debug and develop on your HTC Desire HD mobil and possible most of HTC mobiles. HTC One, Sensation, Magic and more. Eventhough you have enabled USB debugging.

Posted in Android, ErrorFix Tagged with: ,

Android Calculate Time Between Two

  Use a Date object: Date interestingDate = new Date(); You can find the different in milliseconds between the actual current date and interestingDate by doing: long time = (new Date()).getTime() – interestingDate.getTime()  

Posted in Android, Tips and Tricks Tagged with: ,

Android Follow Test Method Naming Conventions

When naming test methods, you can use an underscore to separate what is being tested from the specific case being tested. This style makes it easier to see exactly what cases are being tested. For example: testMethod_specificCase1 testMethod_specificCase2 void testIsDistinguishable_protanopia() { ColorMatcher

Posted in Android, Tips and Tricks Tagged with: ,

Android Be Consistent

Our parting thought: BE CONSISTENT. If you’re editing code, take a few minutes to look at the code around you and determine its style. If they use spaces around their if clauses, you should too. If their comments have little

Posted in Android, Tips and Tricks Tagged with: ,

Android Log Sparingly

While logging is necessary it has a significantly negative impact on performance and quickly loses its usefulness if it’s not kept reasonably terse. The logging facilities provides five different levels of logging. Below are the different levels and when and

Posted in Android, Tips and Tricks Tagged with: ,

Eclipse Java TODO Comments

Use TODO comments for code that is temporary, a short-term solution, or good-enough but not perfect. TODOs should include the string TODO in all caps, followed by a colon: // TODO: Remove this code after the UrlTable2 has been checked

Posted in Android, Tips and Tricks Tagged with: , ,

Android Treat Acronyms as Words

Treat acronyms and abbreviations as words in naming variables, methods, and classes. The names are much more readable: Good Bad XmlHttpRequest XMLHTTPRequest getCustomerId getCustomerID class Html class HTML String url String URL long id long ID Both the JDK and

Posted in Android, Tips and Tricks Tagged with: ,

Android Use Standard Java Annotations

Annotations should precede other modifiers for the same language element. Simple marker annotations (e.g. @Override) can be listed on the same line with the language element. If there are multiple annotations, or parameterized annotations, they should each be listed one-per-line

Posted in Android, Tips and Tricks Tagged with: ,