SMS Receiver is a library built on top of the deprecated SMSLib V3.5.x to read SMS from 3G USB modem.
-
The original SMSLib has dependency towards RXTX, which mostly only work well with Java 7 nowadays.
-
RXTX is not setup friendly - The jar file and binary need to be pasted into inner JRE folder of JDK installation path.
-
SMS Receiver solves this problem by replacing rxtx with its fork, nrjavaserial, which works well with Java 11 and no more manual work to copy-paste rxtx jar and its binary.
If you are on Maven, add this to pom.xml
<dependency>
<groupId>com.chunhoong</groupId>
<artifactId>sms-receiver-lib</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>
If you are on Gradle, add this to build.gradle
implementation 'com.chunhoong:sms-receiver-lib:1.0.2'
// Obtain com port number as shown in: https://github.com/raw/chunhoong/sms-receiver/master/doc/screenshot.png
int comPortNumber = 5;
// Start sms receiver
SmsReceiver.start(comPortNumber);
SmsReceiver.addListener(sms -> { /* You can access your incoming sms from here. */ });
SmsReceiver.once(sms -> {
// You can access your incoming sms from here.
});
int listenerId = SmsReceiver.addListener(sms -> { /* You can access your incoming sms from here. */ });
// Remove listener by passing in listenerId.
SmsReceiver.removeListener(listenerId);
// Assume three listeners are added.
SmsReceiver.addListener(sms -> { /* You can access your incoming sms from here. */ });
SmsReceiver.addListener(sms -> { /* You can access your incoming sms from here as well. */ });
SmsReceiver.addListener(sms -> { /* You can access your incoming sms from here too. */ });
// Remove all three listeners.
SmsReceiver.removeAllListeners();
SmsReceiver.stop();
- Thanasis Delenikas for SMSLib
- Neuron Robotics for nrjavaserial.