Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

38
LINES

< > BotCompany Repo | #1002651 // Android: Try to start the JavaX service and add a web chat bot to it

JavaX source code (Android) [tags: use-pretranspiled] - run with: the app

Libraryless. Click here for Pure Java version (893L/7K/21K).

!752

import android.content.*; // Intent
import android.app.*; // Activity

p {
  Class serviceClass = Class.forName("de.tinybrain.javax_allperms.PermanentService");
  print("serviceClass: " + serviceClass);
  if (serviceClass == null) ret;
  
  Activity context = getAndroidContext();
  print("Context: " + context);
  
  context.startService(new Intent(context, serviceClass)); 
  print("Service should be started, looking for instance.");

  O service = null;
  for (int i = 0; i < 20*60; i++) { // 60 seconds
    sleep(50);
    service = get(serviceClass, "instance");
    if (service != null) break;
  }
  
  if (service == null) { print("woot no service?"); ret; }

  Thread thread = new Thread("Phone Bot") {
    public void run() {
      for (int i = 0; i < 3; i++) {
        sayInWebChat("Phone Bot", "I am running on Android! " + unixSeconds());
        sleepSeconds(60);
      }
    }
  };
  
  call(service, "addThread", thread);
  
  print("Thread added! Check web chat...");
}

Author comment

Began life as a copy of #1002649

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, nbgitpuheiab, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002651
Snippet name: Android: Try to start the JavaX service and add a web chat bot to it
Eternal ID of this version: #1002651/1
Text MD5: d090e60e2c308fe1fa645f7d1d3895fd
Transpilation MD5: 8f9670b8f7b15a89f787cba75cbf45ce
Author: stefan
Category: javax
Type: JavaX source code (Android)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-09 21:58:18
Source code size: 1028 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 520 / 543
Referenced in: #1002656 - Register the "toast" demo boot program
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)