Code

Code

Android statusbar icons to black.

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

http://stackoverflow.com/a/26637752/1015731

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

http://stackoverflow.com/questions/588004/is-floating-point-math-broken

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
    }
});

http://stackoverflow.com/questions/3149216/how-to-listen-for-a-webview-finishing-loading-a-url

Handling Orientation Changes on Android Fragment

Fragment.setRetainInstance(true);

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:

http://code.hootsuite.com/orientation-changes-on-android/

jQuerify.js - jQuerify Bookmarklet

jQuerify Bookmarklet


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

http://www.jondev.net/articles/Combining_2_Images_in_Android_using_Canvas

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.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(uri, socketMessageDataFile.getMimeType());

startActivity(intent);



Subscribe to: Posts (Atom)