Quantcast
Channel: Jontas » Java
Browsing latest articles
Browse All 10 View Live

Android: Rotate a bitmap

Here is a small sample that will rotate a bitmap. Bitmap animation = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.eye_rotate, mBitmapOptions);   Bitmap bitmap =...

View Article



Sony Smart Extras (Smartwatch) Keeping the screen on – controlling the screen...

In the utils package there is a function that can be used to control the screen state. /** * Set the accessory screens state. * * @see Control.Intents#SCREEN_STATE_AUTO * @see...

View Article

Java safe conversion of float to int

In most cases this is really not needed, if possible please keep the float as a float and work with it as such, but if needed the following works public static Integer floatToInteger(float value){ if...

View Article

Android garbage collection types

We are all used to seeing lines like “D/dalvikvm( 8285): GC_CONCURRENT freed 494K, 9% free 14648K/16071K, paused 2ms+2ms” in the logcat, but what does the types mean (why is the device Garbage...

View Article

Android: Suppressing the warning about using px in layout xml

When working with for instance the Sony SmartWatch there is a need to specify layout for the Watch in pixels (not device pixels) – as the SmartWatch is a fixed size and not dependent of the device it...

View Article


Android set background color of ActionBar

Here is a snipet that will set the background color of a ActionBar to a hexcolor. final ActionBar bar = getActionBar();   bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0,...

View Article

Android resize a bitmap

Here is a snippet to scale down a bitmap – the original bitmap still needs to fit on memory though InputStream bitmap = mContext.getAssets().open("image.file"); Bitmap scaledBitmap=...

View Article

Java: Creating a enum and converting from a string to the Enum

Here is a simple example of how create a Enum and how to convert from a String to the Enum (the common reason for doing this would be is we at some point have for OurEnum.toString() and now wishes to...

View Article


Java: Adding a Element under an Element (or Converting a Element to a Node)

When using Document a Element can only be appended with a Node, but what if we have a Element ? Easy, Element extends Node so just pass the Element along and all is well import org.w3c.dom.Document;...

View Article


Java: Getting the Document from a Node or Element

When we for instance wishes to add a new element we need to pass along the document. If we have a element or a node we can get the document that way. Simply call getOwnerDocument and we are good....

View Article
Browsing latest articles
Browse All 10 View Live




Latest Images