HelloWorld: Basic Service and Independent Receiver

This article demonstrate a HelloWorld RTDroid application, which implements a basic service (HelloWorldService) and an independent receiver (HelloWorldService). Fig. 1 shows the declaration of HelloWorldService, Fig.2 and Fig.3 list simplified application implementation.

<!-- Basic service with 80 priority, it starts immediately after RTDroid system bootstrap   -->
<service android:name="rtdroid.demo.HelloWorldService">
  <rtdroid:priority scheduler="FIFO" priority="80"/>
  <rtdroid:scopeSizes total="500K" persistent="250K" release="250K"/>
  <intent-filter rtdroid:realtime="true" rtdroid:concurrentCount="1" 
            rtdroid:role="publisher">
    <action android:name="HelloWorldEvent"/>           
  </intent-filter>
</service>
<!-- Independent receiver with 80 priority, it listens on Intents, called "HelloWorldEvent". -->
<receiver android:name="rtdroid.demo.HelloWorldReceiver">
  <rtdroid:priority scheduler="FIFO" priority="70"/>
  <rtdroid:scopeSizes total="500K" persistent="250K" release="250K"/>
  <intent-filter rtdroid:realtime="true" rtdroid:concurrentCount="1" 
            rtdroid:role="subscriber">
    <action android:name="HelloWorldEvent"/>           
  </intent-filter>
</receiver>
<!-- Intent broadcasting channel -->
 <rtdroid:channel name="HelloWorldEvent" type="broadcast_intent">        
  <data rtdroid:size="4" android:mimeType="application/rtdroid.int" />   
</rtdroid:channel>
Fig.1 HelloWorld Application Manifest
 1 public class HelloWorldService extends RealtimeService {
 2   @Override
 3   public void onCreate() {
 4     System.out.println("Hello World Service -- onCreate()"); 
 5   }
 6   @Override
 7   public int onStartCommand(Intent i, int f, int id) {
 8       System.out.println("Hello World Service -- onStartCommand(...)"); 
 9   }
10   ...
11   @Override
12   public void onDestroy() {
13     System.out.println("Hello World Service -- onDestroy()"); 
14   }
15 }
Fig.2 HelloWorld - Basic Service
1 public class HelloWorldReceiver extends RealtimeReceiver {
2   @Override
3   public void onReceive(Context ctx, Intent intent) {
4     System.out.println("Hello World Receiver -- onReceive()"); 
5   }
6 }
Fig.3 HelloWorld - Independent Receiver