Android statusbar icons to black.

<item name="android:windowLightStatusBar">true</item>

0.1 + 0.2 == 0.3 Is it wrong?

0.1 + 0.2 == 0.3
-> false

0.01 + 0.02 == 0.03
-> true

0.1 + 0.2
-> 0.30000000000000004

Binary floating point math is like this. In most programming languages, it is based on the IEEE 754 standard. JavaScript uses 64-bit floating point representation, which is the same as Java's double. The crux of the problem is that numbers are represented in this format as a whole number times a power of two; rational numbers (such as 0.1, which is 1/10) whose denominator is not a power of two cannot be exactly represented.


Add finish loading listener for WebView on Android

mWebView.setWebViewClient(new WebViewClient() {
   public void onPageFinished(WebView view, String url) {
        // do your stuff here

Handling Orientation Changes on Android Fragment


Calling setRetainInstance(true) on a Fragment is similar to setting the android:configChanges flag on an Activity. It signals to Android that you want to continue using the same instance of the current Fragment, so all of your member variables will remain untouched. If you rotate your device when you have an Activity that is NOT using the configChanges flag and a Fragment that IS being retained, the following lifecycle methods will be called on the Fragment:

jQuerify.js - jQuerify Bookmarklet

jQuerify Bookmarklet

Combining 2 Images in Android using Canvas (Side by Side)

public Bitmap combineImages(Bitmap c, Bitmap s) { // can add a 3rd parameter 'String loc' if you want to save the new image - left some code to do that at the bottom 
    Bitmap cs = null; 
    int width, height = 0; 
    if(c.getWidth() > s.getWidth()) { 
      width = c.getWidth(); 
      height = c.getHeight() + s.getHeight(); 
    } else { 
      width = s.getWidth(); 
      height = c.getHeight() + s.getHeight(); 
    cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); 
    Canvas comboImage = new Canvas(cs); 
    comboImage.drawBitmap(c, 0f, 0f, null); 
    comboImage.drawBitmap(s, 0f, c.getHeight(), null); 
    // this is an extra bit I added, just incase you want to save the new image somewhere and then return the location 
    /*String tmpImg = String.valueOf(System.currentTimeMillis()) + ".png"; 
    OutputStream os = null; 
    try { 
      os = new FileOutputStream(loc + tmpImg); 
      cs.compress(CompressFormat.PNG, 100, os); 
    } catch(IOException e) { 
      Log.e("combineImages", "problem combining images", e); 
    return cs; 

Open a file in another app via using file Uri

Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", file);
String mime = getContentResolver().getType(uri);

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, mime);
intent.setDataAndType(uri, socketMessageDataFile.getMimeType());


Subscribe to: Posts (Atom)