Posts

Showing posts from 2016

Check availability of Google Play Services in android

This blog is about how we can check that Google Play service are available or not in Device. First of all, we can Create a method which will check Play services status with Status code. private void checkService ( int statusCode ) { switch ( statusCode) { case ConnectionResult . API_UNAVAILABLE : //API is not available in device break ; case ConnectionResult . NETWORK_ERROR : //Network error break ; case ConnectionResult . RESTRICTED_PROFILE : //Profile is restricted by google. break ; case ConnectionResult . SERVICE_MISSING : //Plat Service is missing break ; case ConnectionResult . SIGN_IN_REQUIRED : //service available but user is not signed in break ; case ConnectionResult . SUCCESS :

How to get custom HTTP Headers PHP

This blog is about how to read All/Custom headers in PHP. Below code is used to get all Headers. $headers = getallheaders(); There is an alternative for getting HTTP headers. apache_request_headers() These functions are getting all HTTP headers like below:- Array ( [ Host ] => localhost [ Connection ] => keep - alive [ Content - Length ] => 171 [ Authorization ] => "My Custom Header Yo Yo!!" [ Postman - Token ] => 4 c6308bd - da37 - 6 fdf - 6806 - f945c59136f8 [ Cache - Control ] => no - cache [ Origin ] => chrome - extension: //fhbjgbiflinjbdggehcddcbncdddomop [ User - Agent ] => Mozilla / 5.0 ( Windows NT 10.0 ; Win64 ; x64 ) AppleWebKit / 537.36 ( KHTML , like Gecko ) Chrome / 54.0 . 2840.71 Safari / 537.36 [ Content - Type ] => application / json [ Accept ] => */* [ Accept - Encoding ] => gzip , deflate , br [ Accept - Language ] =>

How to combine two Bitmap in Android

This blog is about how to combine 2 images in Android programatically. Note: -For this blog I am creating Bitmap instance from drawables. You can get from Camera/web APIs etc.  1. Create 2 Bitmap instance from Drawable. 1 2 3 4 5 Bitmap image1 = BitmapFactory . decodeResource ( getResources (), R . drawable . image_one ); Bitmap image2 = BitmapFactory . decodeResource ( getResources (), R . drawable . image_two ); 2. Create methods combineBitmap with 2 arguments with type of Bitmap and return type is also Bitmap. 1 public Bitmap combineImages ( Bitmap bitmap1 , Bitmap bitmap2 ){} 3. Create new instance of bitmap with bitmap2. 1 Bitmap bit1 = Bitmap . createBitmap ( bitmap2 , 0 , 0 , bitmap2 . getWidth (), bitmap2 . getHeight (), null , true ); 4. Create new Instance of Bitmap with bitmap1 which height is equals to height of bitmap1 and bitmap2. 1 Bitmap cs = Bitmap . createBitmap (