Posts

Showing posts from 2017

interface example

step 1:- create interface class package com.example.myapp import org.json.JSONObject; public interface ApiResponse {     void onApiRespond(JSONObject Resposne); } step 2:-  create async task import android.os.AsyncTask; import android.util.Log; import com.example.digital.CustomSSLSocketFactory; import com.example.digital.Model.Debugger; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.SingleClientConnManager; import org.apache.http.util.EntityUtils; import org.json.JSONException; import org.json.JSONObject; import java.security.KeyStore; ...

Async task with GSON parsing

step 1:-   download below libs https://drive.google.com/open?id=0B1dF4YSBqUooMWFZYUpUQ2MtRTQ https://drive.google.com/open?id=0B1dF4YSBqUooc3I3bDYwZnllbDg https://drive.google.com/open?id=0B1dF4YSBqUooZ3ZmUzVaREhCUVk Step 2:- compile 'com.google.code.gson:gson:2.2.4' Step 3:- packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1' } Step 4:- class MyAsync extends AsyncTask<String, Void, String> { @Override protected void onPreExecute() { ConstantData.displayProgress(BaseActivity.this); } @Override...

Radio Button style

Image
I. Declare custom style in your  styles.xml  file. <style name = "MyRadioButton" parent = "Theme.AppCompat.Light" > <item name = "colorControlNormal" > @color/indigo </item> <item name = "colorControlActivated" > @color/pink </item> </style> II. Apply this style to your  RadioButton  via  android:theme  attribute. <RadioButton android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:checked = "true" android:text = "Radio Button" android:theme = "@style/MyRadioButton" />

Loading image with Glide in android

step 1:- compile 'com.github.bumptech.glide:glide:3.5.2' step 2:- String url="your url"; try { Glide. with (this) .load(url) .into( imageview ); } catch (Exception e) { e.printStackTrace(); }
Manage Android Fragment Back Press Programmatically step 1: -  FragmentManager fragmentManager ; (Declaration part) step 2:-      fragmentManager = getFragmentManager(); fragmentManager .popBackStack( BACK_STACK_ROOT_TAG , FragmentManager. POP_BACK_STACK_INCLUSIVE ); ( onCreate ) step 3:- Add fragment on fragment manager fragmentManager .beginTransaction() .replace(R.id. framLay , fragments) .addToBackStack( BACK_STACK_ROOT_TAG ) .commit(); step 4:- back press @Override public void onBackPressed() { if ( fragmentManager .getBackStackEntryCount()> 1 ) { fragmentManager .popBackStackImmediate(); return ; } super .onBackPressed(); }
Hide Soft Keyboard Programmatically Android this .getWindow().setSoftInputMode (WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_HIDDEN );