Detect sim card availability in the Android dual sim device

Below you can find code which help you find if SIM card available in the device.
There two solutions. One for Android API less than 22 and for Android API greater than or equal to 22.

Problem that dualsim support added in API-22. And we should deal with devices which support dual sim and has API less than 22.

So solution for API less than 22.

You can ask why I’m not checking for phone number. I do this because the phone number is not 100% available. Sim card serial number always available.

Second solution for API greater than or equal to 22

And here is universal solution:

Let me know your solution in comments.

Letsencrypt automatic certificate renew

To make automatic renew you Letsencrypt certificates you need create crontab job.

Here is simple instructions

1. Create /root/ file with content:

2. Make it executable chmod +x /root/
3. sudo crontab -e
4. Add crontab job. Job for running every day at 3:15AM will be next:

/var/log/le-renew.log – log file

Let me know better approach in comments.