Posts

How to make bridge between Android and JavaScript

Now days Web Mobile apps and Hybrid applications are on trends.  This blog is about how we can make a bridge between Web form and android native methods in android apps using JavaScript. Let's start with add basic code to create bridge. First of all create Android project in Android Studio. Create an Activity class and layout file. Now open layout file of activity and add EditText( for typing a message), add button for sending message to webpage and WebView for loading webpage. Your xml layout look like:- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" android:orientation= "vertical" tools:context= "com.aman.webviewcallback.MainActivity" > <EditText a

How to hide Developer option from Android Device

Image
This post is about How to hide developer option from settings app. All Android devices have built-in Developer options. Developer options are useful for debugging applications, check CPU usage etc. Here are steps to hide Developer option from devices. 1. Open Setting application. 2. Open A apps/Application Manager. 3. Search for Settings app and open it. 4. Clear Data of Setting apps. 5. Now you can go back and check for Developer options in Setting app. There is no more Developer option visible in setting application. Please refer the screenshots for help.     Happy Coding :)

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 (

How to do Facebook Login with Custom Button Android

In my previous Facebook Post( http://androidammy.blogspot.in/2015/07/facebooklogin1.html ). I write how to use Facebook default button to login with Facebook. In this blog I am writing about how we can use facebook login functionality from android widget like Button/TextView/ImageView. All the steps are same as last facebook login post. This blog describe that  how to create instance of CallBackManager and LoginManager and how to call Login from click listener. 1.  Create Instance of LoginManager and CallbackManager. com . facebook . login . LoginManager fbLoginManager ; fbLoginManager = com . facebook . login . LoginManager . getInstance (); CallbackManager callbackManager = CallbackManager . Factory . create (); mFbLoginManager . registerCallback ( callbackManager , new FacebookCallback < LoginResult >() { @Override public void onSuccess ( LoginResult loginResult ) { // here write code

Easy way to convert Json to Pojo/Model class of Java

Is It hard for you to create Pojo/Model/Bean classes according to Json result specially when you are using third party libraries like GSON/Jackson? There is very easy and fast way to create Pojo/Beans/Model classes for Json Schema.  Check out the below link to convert your Json response to Java model classes.   http://www.jsonschema2pojo.org/ For Example I want to convert  json data to Gson Pojo class then following are the points to do it. 1. Copy and paste Json to TestEditor displayed in link. 2. Enter my package name and class name. 3. Select Source type to Json. 4. Select annotation style to GSON. Its done here.  Preview the Class structure and copy paste to your model class. Happy Coding :D