How To Create One Time Password Input | Android Studio & Java
Hello guys, this tutorial I will make an OTP Online Time Password input. OTP is a verification code or a one-time password consisting of 6 unique (often numeric) secret characters that are generally sent via SMS or e-mail. Each code sent is generally only valid for 5 minutes.
Okay, first open your Android Studio, then open build.gradle (module.app) then add the following dependencies
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center_vertical" android:background="#0c0f18" tools:context=".MainActivity"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" android:text="MASUKKAN KODE VERIFIKASI" android:textColor="#ffffff" android:textSize="30dp" android:textStyle="bold" android:layout_marginBottom="30dp"/> <in.aabhasjindal.otptextview.OtpTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/otp_view" android:textColor="#ffffff" app:height="90dp" android:layout_gravity="center_horizontal" app:width="50dp" app:bar_enabled="true" app:bar_success_color="#43a047" app:bar_active_color="#ffee58" app:bar_height="2dp" app:length="5" app:otp_text_size="50dp" /> </LinearLayout>
When it's finished the design will look like this
Next, we open MainActivity.java and enter the following code
import androidx.appcompat.app.AppCompatActivity; import in.aabhasjindal.otptextview.OTPListener; import in.aabhasjindal.otptextview.OtpTextView; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private OtpTextView otpTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); otpTextView = findViewById(R.id.otp_view); otpTextView.setOtpListener(new OTPListener() { @Override public void onInteractionListener() { } @Override public void onOTPComplete(String otp) { if (otp.equals("12345")){ otpTextView.showSuccess(); Toast.makeText(MainActivity.this,"Kode Verifikasi Benar "+ otp, Toast.LENGTH_LONG).show(); } else{ otpTextView.showError(); Toast.makeText(MainActivity.this,"Kode Verifikasi Salah", Toast.LENGTH_LONG).show(); } } }); } }
In the code above I make a condition if the OTP TextView type the number "12345" then the OTP code is declared correct, and if otherwise it is declared false. After all is done and there are no errors, the program is ready to run.
Source Code : Github
Where is the dependency?
ReplyDeleteIf you're looking for help in using it, just dial Quickbooks Customer Service +1 855-675-3194 to speak with a live representative.
ReplyDeleteDigital marketing and eCommerce services are becoming increasingly important for businesses of all sizes. By joining us, you can boost your business online and take advantage of our eCommerce platform. With zero commission fees, you can sell your products easily and reach a larger audience than ever before. With our digital marketing services, you can also reach new customers and grow your business. Contact us today to learn more about how we can help you boost your business online.
ReplyDeleteDuelbits Promo Code in 2022
ReplyDeleteGet Duelbits Referral Code Now! Just register with Duelbits Promo Code “freecoupon” and claim your Duelbits Bonus today! https://casinoonline-bet.com/duelbits-promo-code/
Glownosity Skin Bar is the Best Skincare Brand. All the services provide in skincare such as soaps, Lip Scrubs, Body butter, Body Scrubs, Bathroom Essentials, Face Masks, Sage, Home fragrances & Body Oil. Skincare Services Waxing And Handmade Skin Care Products are in Las Vegas, NV in United State. Glownosity is a symbol of loyalty and trust. Get the best Skincare Services and detailed information please visit our website https://glownosity.us/
ReplyDeleteHello there! I just want to offer you a big thumbs up for your great info you have right here on this post. I'll be coming back to your web site for more soon.
ReplyDeletehttps://www.webranksindia.com/
QuickBooks to get help with the software or to get help with other important financing needs. You can also contact them for help with your business credit cards. QuickBooks is a business accounting software for small businesses. It helps you keep track of your finances and plan for the future. This software is easy to use, affordable, and has a large user base. For help with QuickBooks or other important financing needs contact them at QuickBooks Customer Service
ReplyDeleteAgency Partner Interactive (API) is not your average digital agency. We work to understand your business and leverage technology and marketing solutions to generate revenue and increase profits. To do this, we don’t hire just anyone.
ReplyDeleteAgency partner.https://agencypartner.com/services/web-development/
Lounge in the shade of a palm tree next to magnificent turquoise waters, soothe your tired feet in cool white sands, and revel in spectacular views of the Pitons’ volcanic peaks! St. Lucia is the breathtaking Caribbean oasis you’ve been seeking. Get away from life’s hustle and bustle and explore this tranquil island’s small fishing villages, lush mountains, beautiful waterfalls, and colorful markets. https://www.islandlifecaribbean.com/best-st-lucia-all-inclusive-resorts/
ReplyDelete