Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Structure of an Android application  (Read 676 times)

DrKillPatient

  • Bay Watcher
  • The yak falls infinitely
    • View Profile
Structure of an Android application
« on: November 29, 2015, 04:21:25 pm »

I've recently been attempting to make an Android application to catch SMS when the phone receives it and send it to my computer via Bluetooth, and vice versa. I have some understanding of the SMS and Bluetooth components, however, linking everything together has proved completely infuriating, as there seems to be about six thousand ways to do the same thing in Java/Android and I can never be sure which one is right. I wonder if anyone here has an intuition for how I should structure my application.

The functionality is as follows.
As long as the phone is connected to a client (e.g. on a computer) via Bluetooth:
  1. If SMS is received on the phone, it is sent to the computer via BT.
  2. The client on the computer can "send SMS" via the phone, issuing a request over Bluetooth for the phone to send a given SMS message.
I want to have a GUI that can start and stop this service, but make the service otherwise independent of the GUI (i.e. you can close it freely after it's started).

I have code that sends/receives SMS and Bluetooth data, but I don't know how to tie it together — should one service encompass both, should they be started as separate services, how should they communicate between one another and the GUI, etc. Most tutorials I've found thus far have been less than helpful, as they just tell me how to write the code but not really how to use it.
Logged
"Frankly, if you're hanging out with people who tell you to use v.begin() instead of &v[0], you need to rethink your social circle."
    Scott Meyers, Effective STL

I've written bash scripts to make using DF easier under Linux!

Muz

  • Bay Watcher
    • View Profile
Re: Structure of an Android application
« Reply #1 on: December 03, 2015, 12:51:01 pm »

Sounds like something IFTTT can do.
Logged
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

zombie urist

  • Bay Watcher
  • [NOT_LIVING]
    • View Profile
Re: Structure of an Android application
« Reply #2 on: December 03, 2015, 11:27:58 pm »

I think its probably simpler if you keep the services for the bluetooth and sms separate. Then when you get a SMS, you can do an Intent and let your bluetooth service send data to your computer and the same the other way around. When your bluetooth service receives data, it sends an Intent to the sms service which then sends the SMS.

I haven't done this in a while so I'm not 100% sure.
Logged
The worst part of all of this is that Shakerag won.

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: Structure of an Android application
« Reply #3 on: December 07, 2015, 03:00:58 pm »

Wouldn't a linux shellscript be the best solution here? Seriously--

Android lives on top of Linux. The SMS text database lives in the form of a SQLite formated database file. It's location is android version dependent, but the format of the file itself is conserved. The hooks the android API provide just gives access to this file as a wrapper.

If I wanted to do this, I would use a rooted phone so that I could see the filesystem properly, and then just use a shellscript to find the location of the database file with:

find / -name "*mmssms*"

Then grab the filesystem location into a local shellscript variable.  After that, I would use linux console version of SQLite to read and pass the queried information from the database to say, something like Sendmail.

The whole thing could be set up to run completely transparently to android, underneath android, as a cron job.
Logged