Android Signature Pad Example

In this article i am going to explain about how to create android signature pad with example. Android signature pad is commonly used in e-commerce applications to collect customer signature while delivering product.

Android Signature Pad Example

Introduction:

In my previous article i have explained about Send Email Programmatically in Android,Android contact picker exampleConvert speech to text in android with example code. In this article let us see how to create android signature pad with example.

Explanation:

Create a new project and name it as Android Signature Pad. Refer how to create new project in android studio to create a new project.

Once the project is created add com.github.gcacace:signature-pad:1.2.1 dependency in app level build.gradle.

After that add permissions to WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE in android manifest.xml file.

The complete modified androidmanifest.xml is given below.

If you are using android marshmallow or above device for testing then you need to get runtime permission. For runtime permissions refer how to get runtime permission in android.

After adding required permissions in android manifest file and required dependencies in app build.gradle file now update the SignatureActivity.java file as below.

In the above code OnCreate method first

1.Get the widget reference from XML layout

2. After that check If the android version is greater than lollipop to ask for run time permission.

3. And then disable SaveSignature and ClearSignature buttons at the start of the page.

4. And then define setOnSignedListener event listener for singnaturePad.

5.Inside setOnSignedListener we need to override onStartSigning(),onSigned() and onClear() methods. Now inside onSigned() method enable SaveSignature and ClearSignature butons.

6.After that defilne OnClick listener for btnSaveSignature button.OnClicking btnSaveSignature button get the signature from signaturepad as bitmap and save it to a new file.

7.After that defilne OnClick listener for btnClearSignature button.OnClicking btnClearSignature button clear the signature pad by calling objSignaturePad.clear() method.

Below is the layout file used to render the design.

Now if you click on ViewSignature button it will navigate to ViewSignatureActivity.java. It will display the captured signature in the imageview. Below is the complete code.

Here is activity_view_signature.xml layout file.

Below is the strings.xml resource file.

 Demo of Android Signature Pad Example

Now if you run the application you will get the  below output.

Android Signature Pad Example Output 1 Android Signature Pad Example Output 2 Android Signature Pad Example Output 3 Android Signature Pad Example Output 4

Download Source code Of Android Signature Pad Example

Sourcecode of Convert speech to text in android with example code

Leave a Reply

Your email address will not be published. Required fields are marked *