1313import net .sharksystem .asap .android .apps .ASAPActivity ;
1414import net .sharksystem .asap .android .R ;
1515import net .sharksystem .asap .android .apps .ASAPApplication ;
16+ import net .sharksystem .asap .android .apps .ASAPMessageReceivedListener ;
1617import net .sharksystem .asap .android .apps .ASAPOnlineMessageSenderAndroidUserSide ;
18+ import net .sharksystem .asap .apps .ASAPMessages ;
1719
1820import java .io .IOException ;
1921
20- public class ASAPServiceTestActivity extends ASAPActivity {
22+ public class ASAPExampleActivity extends ASAPActivity implements ASAPMessageReceivedListener {
2123 private static final CharSequence TESTURI ="asap://testuri" ;
2224 private static final CharSequence TESTMESSAGE = "Hi there from asap writing activity" ;
2325 private ASAPOnlineMessageSenderAndroidUserSide asapOnlineSender ;
2426
25- public ASAPServiceTestActivity () {
27+ public ASAPExampleActivity () {
2628 super (ASAPApplication .getASAPApplication ());
2729 }
2830
@@ -31,6 +33,9 @@ protected void onCreate(Bundle savedInstanceState) {
3133 super .onCreate (savedInstanceState );
3234 setContentView (R .layout .activity_main );
3335
36+ // add as message received listener
37+ this .getASAPApplication ().addASAPMessageReceivedListener (URI , this );
38+
3439 // create broadcast receiver
3540 ExampleASAPBroadcastReceiver br = new ExampleASAPBroadcastReceiver ();
3641 IntentFilter filter = new IntentFilter ();
@@ -76,6 +81,21 @@ else if(view == findViewById(R.id.startDiscoverableAndDiscovery)) {
7681 }
7782 }
7883
84+ ///////////////////////////////////////////////////////////////////////////////////////////
85+ // asap message receiver example implementation //
86+ ///////////////////////////////////////////////////////////////////////////////////////////
87+
88+ @ Override
89+ public void asapMessagesReceived (ASAPMessages messages ) {
90+ StringBuilder sb = new StringBuilder ();
91+ sb .append ("received: | " );
92+ sb .append (messages .getFormat ());
93+ sb .append ( "| " );
94+ sb .append (messages .getURI ());
95+ Log .d (this .getLogStart (), "asap message arrived: " + sb .toString ());
96+ Toast .makeText (this , sb .toString (), Toast .LENGTH_LONG ).show ();
97+ }
98+
7999 ///////////////////////////////////////////////////////////////////////////////////////////
80100 // helps debugging //
81101 ///////////////////////////////////////////////////////////////////////////////////////////
0 commit comments