Posts

Showing posts from February, 2018

SOAP Client using ksoap2 in Android - Kotlin

Image
Introduction: SOAP stands for Simple Object Access Protocol. It is XML-based protocol that allows programs that run on different operating systems (like Windows, Linux, etc) to communicate using HTTP and XML. Pros: Security - SOAP provides its own security known as WS Security . Platform Independent - SOAP web services can be written in any programming language and executed in any platform Cons: Slow - It uses XML format that must be parsed, to be read. It defines many standards to be followed while developing. So its slow and consumes more bandwidth and resource. WSDL dependent - It uses WSDL mechanism and doesn't have any other mechanism to discover the service. Things to know: The following are the things we have to know before we proceed further:                     URL - It is the URL of WSDL file.                     NAMESPACE - It is targetNamespace in WSDL.                                         METHOD_NAME - It is the met

Using Camera in Android - Kotlin

Image
Nowadays, most of our Android app require access to Camera to capture picture or Video. We can do that in two ways.                                 (i) Using built-in Camera,                                 (ii) Using custom Camera. Using Built-in Camera In this post, Let's see how to use the built-in camera to capture images and save it. Its a simple way to capture pics. We can use the mobile's built-in camera app using Intent.  val REQUEST_IMAGE_CAPTURE = 1 private fun takePictureIntent() { val takePictureIntent = Intent(MediaStore . ACTION_IMAGE_CAPTURE) if (takePictureIntent . resolveActivity(packageManager) != null) { startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE) } } After the picture has been captured, the result will received on onActivityResult method. There, we can get the data, in Bitmap form. override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

RecyclerView with different number of columns using SpanSizeLookup

Image
We already know how to design RecyclerView. But how to create RecyclerView with different columns depending on its row? Like below image? Yeah, we can do that, by using two different layouts with different viewType on Adapter. Another way is do some logic to do so. But, it's cumbersome. Luckily, we have another simple way to do that using SpanSizeLookUp . Let's see how to implement that in this post. Implementation: build.gradle Include the following in app-level gradle file. implementation 'com.android.support:recyclerview-v7:27.0.2' implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta5' recycler.xml <?xml version= "1.0" encoding= "utf-8" ?> <android.support.constraint.ConstraintLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "match_parent" android:layout_height= "match_parent" xmlns:ap

Bottom Navigation using design Library in Android - Kotlin

Image
Introduction: Let's implement BottomNavigationView in our layout using Design Support Library. First, we have to go through the factors like, when  and how to use that. When to use? As per Material Design specs, the following criteria is there: (a) Tabs (TabLayout) - Should be used when there are two navigations. (b) Bottom Navigation - Should be used when there are 3 to 5 navigations. (c) Navigation Drawer - Should be used when there are 6 or more navigations. Also to remember that, Viewpager shouldn't be used with BottomNavigationView. You can read the complete design specs, here . How to use? BottomNavigationView have to be added  at the bottom of the screen. Also, the following are some of the important attributes: app:itemBackground - to apply background color  app:itemTextColor - to apply the color for the text of BottomNavigation item. app:itemIconTint - to apply the color for the icon of BottomNavigation item. app:menu