Skip to main content

Posts

Network Security Exception in Android Retrofit Cleartext HTTP traffic not permitted

Create One directory in res/xml Create file in xml directory Past give below code : < network-security-config > < base-config cleartextTrafficPermitted= "true" /> < domain-config > < domain includeSubdomains= "true" >www.xyz.com</ domain >> < trust-anchors > < certificates src= "system" /> </ trust-anchors > </ domain-config > </ network-security-config > Add one Line into AndroidMenifest.xm File in application tag : android :networkSecurityConfig= "@xml/yourfilename" android :usesCleartextTraffic= "true"

Json Parsing Using Retrofit Library

1] Add Libraries in Gradle(module.app) in  dependencies compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.3.0' 2]Create APIClient.java public class APIClient { private static final String BASEURL1 = "https://finddata.com" ; //contacts/ public static Retrofit getClient() { Retrofit retrofit = new Retrofit.Builder() .baseUrl( BASEURL1 ) .addConverterFactory(GsonConverterFactory. create ()).build(); return retrofit; } } 3]Create APInterface public interface APInterface { @GET ( "finddata/api/fetch.php" ) Call<Result> getUser( @Query ( "results" ) int result, @Query ( "number" ) int num @Query ( "number" ) int num1 ); } 4]Do in MainActivity.java private void getData() { APInterface api=APIClient. getClient ().create(APInterfa...

Fragment In Android

What is Fragment ? *A Fragment represents a behavior or a portion of user interface in an Activity . *You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a        fragment in multiple activities. *fragment as a modular section of an activity , which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running * A fragment must always be embedded in an activity and the fragment's lifecycle is directly affected by the host activity's lifecycle.   * For example, when the activity is paused, so are all fragments in it, and when the activity is destroyed, so are all fragments. *When you perform such a fragment transaction , you can also add it to a back stack that's managed by the activity—each back stack entry in the activity is a record of the fragment transaction that occurred. The back stack allows the user to reverse a frag...

Set Youtube Video Quality With Speecific Size In Android Application

Append the following parameter to the Youtube-URL:                            240p: &vq=small                           360p: &vq=medium                           480p: &vq=large                           720p: &vq=hd720 For instance:                       src="http://www.youtube.com/watch?v=oDOXeO9fAg4"            ...

Difference between px, dp, dip and sp in Android

Main Difference Between px,sp,dip is px is one pixel. sp is scale-independent pixels. dip is Density-independent pixels.                                        1> sp for font size                    2>dip for everything else                           3>dip==dp