All in ONE Demo Donload demo from here:
https://github.com/jinatonic/confetti
Simple Demo Donload demo from here:
https://drive.google.com/open?id=1wGVa-UqDM3AXJkZHUzW5_fkMFH8K5Vv7


public class Utilities { public void showToast(Context context, String message) { Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG); View toastView = toast.getView(); // This'll return the default View of the Toast. /* And now you can get the TextView of the default View of the Toast. */ TextView toastMessage = (TextView) toastView.findViewById(android.R.id.message); toastMessage.setTextSize(25); toastMessage.setTextColor(Color.WHITE); toastMessage.setGravity(Gravity.CENTER); toastMessage.setCompoundDrawablePadding(16); toastView.setBackgroundColor(Color.CYAN); toast.show(); } public void hideSoftKeyboard(Context mContext, View view) { if (view != null) { InputMethodManager inputMethodManager = (InputMethodManager) mContext.getSystemService(INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } } /** * Shows the soft keyboard */public void showSoftKeyboard(Context mContext, View view) { if (view != null) { InputMethodManager inputMethodManager = (InputMethodManager) mContext.getSystemService(INPUT_METHOD_SERVICE); view.requestFocus(); inputMethodManager.showSoftInput(view, 0); } }public static void showAlertDialog(Context context, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Title"); builder.setMessage(message); builder.setCancelable(false); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); }public void showToastColor(Context context, String message) { Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG); View toastView = toast.getView(); TextView toastMessage = (TextView) toastView.findViewById(android.R.id.message); toastMessage.setTextSize(25); toastMessage.setTextColor(Color.WHITE); toastMessage.setGravity(Gravity.CENTER); toastMessage.setCompoundDrawablePadding(16); toastView.setBackgroundColor(Color.CYAN); toast.show(); }public static String ordinal(int i) { String[] sufixes = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; switch (i % 100) { case 11: case 12: case 13: return i + "th"; default: return i + sufixes[i % 10]; } }public static String getCertificateSHA1Fingerprint(Context context) { PackageManager pm = context.getPackageManager(); String packageName = context.getPackageName(); int flags = PackageManager.GET_SIGNATURES; PackageInfo packageInfo = null; try { packageInfo = pm.getPackageInfo(packageName, flags); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } Signature[] signatures = packageInfo.signatures; byte[] cert = signatures[0].toByteArray(); InputStream input = new ByteArrayInputStream(cert); CertificateFactory cf = null; try { cf = CertificateFactory.getInstance("X509"); } catch (CertificateException e) { e.printStackTrace(); } X509Certificate c = null; try { c = (X509Certificate) cf.generateCertificate(input); } catch (CertificateException e) { e.printStackTrace(); } String hexString = null; try { MessageDigest md = MessageDigest.getInstance("SHA1"); byte[] publicKey = md.digest(c.getEncoded()); hexString = byte2HexFormatted(publicKey); } catch (NoSuchAlgorithmException e1) { e1.printStackTrace(); } catch (CertificateEncodingException e) { e.printStackTrace(); } return hexString; } public static String byte2HexFormatted(byte[] arr) { StringBuilder str = new StringBuilder(arr.length * 2); for (int i = 0; i < arr.length; i++) { String h = Integer.toHexString(arr[i]); int l = h.length(); if (l == 1) h = "0" + h; if (l > 2) h = h.substring(l - 2, l); str.append(h.toUpperCase()); if (i < (arr.length - 1)) str.append(':'); } return str.toString(); }}

//desing intentfilter name
var intentfilterSetList = "set_list"
lateinit var brSetList: BroadcastReceiver var ifSetList: IntentFilter = IntentFilter(AppConstant.intentfilterSetList)
brSetList = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { // do your stuff } } // register broadcast in activity
activity.registerReceiver(brSetList, ifSetList)
// send broadcast from anywhere
sendBroadcast(Intent(AppConstant.intentfilterSetList))
RecyclerViewClick.ktinterface RecyclerViewClick {
fun onItemClick(position: Int)
}
// declare interface in activity
internal var recyclerListener: RecyclerViewClick = object : RecyclerViewClick { override fun onItemClick(position: Int) { // do you stuff } }// connection between two class using interface// first placeadapter = ArtistSelectListAdapter(context, artistList, recyclerListener, true)// for call interfaceholder.rlTop.setOnClickListener(View.OnClickListener { recyclerListener.onItemClick(position) // this line call interfacewhere declare })
if (!Patterns.EMAIL_ADDRESS.matcher(edt_email.getText().toString()).matches()) {
}
2) First charactor dont allow to "."(dot) or " "space.
edt_email.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { try { String inputChar = edt_email.getText().toString(); if (edt_email.getText().length() == 1) { if (inputChar.equalsIgnoreCase(".") || inputChar.equalsIgnoreCase(" ")) { edt_email.setText(""); } } } catch (Exception e) { e.printStackTrace(); } } });
1) First character allow only "+" sign.
edt_mobile.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { try { String last = edt_mobile.getText().toString(); String inputChar = last.substring(last.length() - 1); if (edt_mobile.getText().length() > 1) { if (inputChar.equalsIgnoreCase("+")) { edt_mobile.setText(edt_mobile.getText().toString().substring(0, edt_mobile.getText().length() - 1)); edt_mobile.setSelection(edt_mobile.getText().length()); } } } catch (Exception e) { e.printStackTrace(); } } });
2) Only allow particular digits (only allow declared digit or characters)<string name="mobile_digits">+9876543210</string>in xmlandroid:digits="@string/mobile_digits"
public static void getTimeFromGoogleServerNoAsync(final Context context) { try { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(new HttpGet("https://google.com/")); StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() == HttpStatus.SC_OK) { String dateStr = response.getFirstHeader("Date").getValue(); //Here I do something with the Date String //System.out.println("Google Time "+dateStr); PreferencesHelper preferencesHelper = new PreferencesHelper(context); preferencesHelper.setGoogleTime(dateStr); SimpleDateFormat sdf3 = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH); Date d1 = null; try { d1 = sdf3.parse(dateStr); } catch (Exception e) { e.printStackTrace(); } System.out.println("OTP Google Time" + d1); Calendar calendar = Calendar.getInstance(); System.out.println("OTP Device Time" + calendar.getTime()); } else { //Closes the connection. response.getEntity().getContent().close(); throw new IOException(statusLine.getReasonPhrase()); } } catch (ClientProtocolException e) { Log.d("Response", e.getMessage()); } catch (IOException e) { Log.d("Response", e.getMessage()); } }
// create secrete key of sting token/key String keystr = "hkjhgsdghhg"; byte[] bytearr = new Base32().decode(keystr); SecretKey secret = new SecretKeySpec(bytearr, 0, bytearr.length, "AES"); String password = "123456";
//Encrept byte[] cipherText = encryptMsg(password, secret))
public static byte[] encryptMsg(String message, SecretKey secret)
throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidParameterSpecException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException
{
/* Encrypt the message. */ Cipher cipher = null;
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, secret);
byte[] cipherText = cipher.doFinal(message.getBytes("UTF-8"));
return cipherText;
}
//Decrept
password = decryptMsg(cipherText, secret))
public static String decryptMsg(byte[] cipherText, SecretKey secret)
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidParameterSpecException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, UnsupportedEncodingException
{
/* Decrypt the message, given derived encContentValues and initialization vector. */ Cipher cipher = null;
cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, secret);
String decryptString = new String(cipher.doFinal(cipherText), "UTF-8");
return decryptString;
}
String currentOTP;
public void genereateOTP(String key) { try { byte[] secret1 = new Base32().decode(key); //Key key = new SecretKeySpec(secret1,0,secret1.length, "DES"); SecretKey key = new SecretKeySpec(secret1, 0, secret1.length, "AES"); TimeBasedOneTimePasswordGenerator totp = new TimeBasedOneTimePasswordGenerator(); Date now = new Date(); Date later = new Date(now.getTime() + TimeUnit.SECONDS.toMillis(timeslice)); System.out.format("Current password: %06d\n", totp.generateOneTimePassword(key, now)); System.out.format("Future password: %06d\n", totp.generateOneTimePassword(key, later)); int generatedOTP = totp.generateOneTimePassword(key, now); currentOTP = String.format("%06d", generatedOTP); } catch (Exception e) { e.printStackTrace(); } }
Change activity name to your cutome Name:-
<screenName name="mp3song.sudokutech.com.googleanalytics.MainActivity">Main Activity</screenName>
Track Custome Event:-
AppController.getInstance().trackScreenView("Home Screen");
Download Demo from Here:-
https://drive.google.com/open?id=18qxpZ4yOyrKHPYubqXjWphgcoOcgkRWf
Open Teminal/cmd --------------- Below steps is for Android 10 or lower Step 1 - Connect the device via USB and make sure debugging is work...