Basically, the app help users register in GLOBE SuperUNLI25 and SuperUNLI150 promos. My inspiration for the app is my frustration in registering to the said promos. I always get a "Please try again" message so I have to keep on resending the keyword.
I would greatly appreciate it if you guys could give feedback or even feature requests to improve the app.
tl;dr if not interested on the internal workings
I decided to explain the internal workings of the app in the context of sharing information and intellectual discussion. Should you find potential problems, better ways to do things, etc I would gladly hear them.
The application will try and retry to register to the promo until (1) you are successfully register, (2) it gives up after 10 attempts [may be modified later] notifying the user, or (3) once you have exceeded the number of requests to the access number for the day. All notifications are done via the notification bar and a vibrate feedback.
It will only retry to send the message after it receives a response from the access number 8888 that registration failed to prevent abuse.
The app has:
- One Activity
- May be launched via the launcher. Has three buttons: subscribe to SuperUNLI25 and 150, and a button to check the balance.
- Two Broadcast Receivers
- SMSReceiver: Receives the intent broadcasted by phone when it receives a message. If there's a pending request initiated thru the Activity, it will read all SMS from 8888 and parse the message. If registration failed but the app hasn't reached its failure threshold of 10, it will try to resend the message thru a Service described later. The Receiver aborts the Broadcast if registration failed, reached maximum requests to access code or not enough balance.
I decided to abort the Broadcast so that no SMS received notification would be received and the message would be discarded. Again, it will only do all of this if there's a pending registration request initiated from the Activity. It will not block messages from other people, or even from 8888 if no request is made.
- GUIUpdater: When the app has reached a certain state (e.g. successful reg, failed reg, exceeded attempts, no load, no signal), an Intent is sent with the status and other relevant information as Extras. This receiver receives those Intent to display the proper message on the GUI. This BroadcastReceiver's Context is my sole Activity.
- One Service
- As much as I don't want to have this Service, I was forced to do it. The Service is the one responsible for sending SMS. I tried sending an SMS using my BroadcastReceiver but I'm having problem with it. My suspicion is that the lifecycle of my BroadcastReceiver ends before it can receive the PendingIntents saying the SMS has been delivered or not. The Service kills itself using the stopSelf() function after doing its task.
The tracking of the state of the app (is it attempting, gave up, got exceeded attempts message or successful) and number of attempts (if attempting) is done using SharedPreferences instead of SQLite for convenience.
P.S. Nahiya naman ako sa haba ng message ko. Sorry in advance if this is not the right forum to discuss these things, just tell me so that I may know.