It is a bit tricky to keep an Android app running in the background, which what you need to do to keep a transmitter going.
The Android Beacon Library does this automatically for scanning purposes, so you could use the library's reference app as a starting point and put the transmission start in the onCreate method of the Application class.
This would keep the transmitter going pretty much forever on Android 5-7. On Android 8 you are limited to running in the background for about 5 minutes out of every 15 unless you build a foreground service.
EDIT
If you wish to advertise several bytes of data, your best bet is to encode it in the 16 byte ID1 (ProximityUUID) field. You can reserve the first few bytes for determining if the beacon is yours, then use the last 10 bytes or so to encode your data. On the receiver side you can use identifier.getBytes()
to convert your first identifier to a byte array so you can access data elements inside of it.