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

24
LINES

< > BotCompany Repo | #1004164 // androidGetPermanentService

JavaX fragment (include)

1  
import android.content.*; // Intent
2  
import android.app.*; // Activity
3  
4  
static O androidGetPermanentService() ctex {
5  
  Class serviceClass = Class.forName("de.tinybrain.javax_allperms.PermanentService");
6  
  print("serviceClass: " + serviceClass);
7  
  if (serviceClass == null) ret null;
8  
  
9  
  Context context = getAndroidContext();
10  
  print("Context: " + context);
11  
  
12  
  context.startService(new Intent(context, serviceClass)); 
13  
  print("Service should be started, looking for instance.");
14  
15  
  O service = null;
16  
  for (int i = 0; i < 20*60; i++) { // 60 seconds
17  
    sleep(50);
18  
    service = get(serviceClass, "instance");
19  
    if (service != null) break;
20  
  }
21  
  
22  
  if (service == null) { print("hm, no service?"); ret null; }
23  
  ret service;
24  
}

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: 575 / 530
Referenced in: [show references]