Archive

Archive for June, 2016

How to check version on google play

Firstly, you need to add this command in gradle file:

compile 'org.jsoup:jsoup:1.9.2'

And then add following code:
Jsoup.connect("https://play.google.com/store/apps/details?id=yourappbundley&hl=en")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6").referrer("http://www.google.com")
.get().select("div[itemprop=softwareVersion]")
.first()
.ownText();
Advertisements
Categories: Android

Save bitmap to location

FileOutputStream out = null;
try {
    out = new FileOutputStream(filename);
    bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance
    // PNG is a lossless format, the compression factor (100) is ignored
} catch (Exception e) {
    e.printStackTrace();
} finally {
    try {
        if (out != null) {
            out.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Categories: Android

How to get screen size on android?

DisplayMetrics displaymetrics = new DisplayMetrics();
mContext.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int screenWidth = displaymetrics.widthPixels;
int screenHeight = displaymetrics.heightPixels;
Categories: Android

ColorFilter

A color filter can be used with a Paint to modify the color of each pixel drawn with that paint. This is an abstract class that should never be used directly.

Subclasses of ColorFilter class

  • ColorMatrixColorFilter
  • LightingColorFilter
  • PorterDuffColorFilter

 

Categories: Android