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

24
LINES

< > BotCompany Repo | #1004164 // androidGetPermanentService

JavaX fragment (include)

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

static O androidGetPermanentService() ctex {
  Class serviceClass = Class.forName("de.tinybrain.javax_allperms.PermanentService");
  print("serviceClass: " + serviceClass);
  if (serviceClass == null) ret null;
  
  Context 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("hm, no service?"); ret null; }
  ret service;
}

Author comment

Began life as a copy of #1002657

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004164
Snippet name: androidGetPermanentService
Eternal ID of this version: #1004164/1
Text MD5: 6003d766c3eeff9c3057a7997c4da6ce
Author: stefan
Category: javax / android
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-09 16:21:36
Source code size: 754 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 571 / 526
Referenced in: [show references]