本文整理汇总了Python中android.AndroidService类的典型用法代码示例。如果您正苦于以下问题:Python AndroidService类的具体用法?Python AndroidService怎么用?Python AndroidService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AndroidService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
def build(self):
if platform == "android":
from android import AndroidService
service = AndroidService('desire sensors service', 'running')
service.start('service started')
self.service = service
status_page = StatusPage()
accelerometer.enable()
compass.enable()
self.gps = gps
self.gps.configure(on_location=self.on_gps_location,
on_status=self.on_gps_status)
self.gps.start()
notification.notify(title="Hello",message="Just Checking")
#vibrator.vibrate(0.2) # vibrate for 0.2 seconds
print("Hello World")
status_page.gps_data = self.gps_data
# Clock.schedule_interval(status_page.update, 1.0 / 10.0) # 10H
Clock.schedule_interval(status_page.update, 1.0) # 1Hz
button=Button(text='Service',size_hint=(0.12,0.12))
button.bind(on_press=self.callback)
status_page.add_widget(button)
switch = Switch()
switch.bind(active=self.callback)
status_page.add_widget(switch)
return status_page
示例2: __init__
def __init__(self, platform):
"""
:param platform: ['android', 'win', 'linux']
:return:
"""
self.files = []
self.titles = []
self.origins = [os.path.abspath(os.path.join(os.curdir, 'composizioni')),
"/sdcard/Mentor",
"C:\\Mao\\Progetti\\Mentor\\sequenze"]
if platform == 'android':
from android import AndroidService
service = AndroidService('Mentor Service', 'running')
service.start('service started')
self.service = service
self.folder_music = "/storage/emulated/legacy/Music/PerAttivita"
elif platform == 'win':
self.folder_music = "C:\\Mao\\Progetti\\Musica\\MusicaSuNexus\\PerAttivita"
else:
self.folder_music = ".\\music"
Logger.info("Folder music: {}".format(self.folder_music))
self.base_folder = None # ToDo more General
for orig in self.origins:
if os.path.exists(orig):
self.base_folder = orig
Logger.debug("MentorLib.Sequences.LoadSequence: Set base dir for sequences {}".format(self.base_folder))
break
示例3: build
def build(self):
config = self.config
self.icon = 'data/graphics/icons/logo.png'
self.title = 'onDemand Controller'
self.weather = Weather_api(key=config.getdefault('hidden',
'weatherapikey',
'12345678'))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
t = s.connect_ex(('127.0.0.1', 4343))
if t != 0:
print(platform)
if platform == 'android':
from android import AndroidService # @UnresolvedImport
service = AndroidService('Controller service', 'running')
service.start('service started')
self.service = service
else:
import subprocess
print(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'service/main.py'))
stat = subprocess.Popen(
['/usr/bin/python2',
os.path.join(os.path.dirname(os.path.abspath(__file__)),
'service/main.py')],
close_fds=True)
print(stat)
return Main(self)
示例4: start_service
def start_service(self,*args):
if platform == 'android':
from android import AndroidService
service = AndroidService('SRN Service','Generating you great headlines')
service.start('service started')
self.service = service
self.service_enabled = True
示例5: build
def build(self):
# the root is created in pictures.kv
self.root
self.osc_id = osc.listen(ipAddr='0.0.0.0', port=activity_port)
if platform == 'android':
from android import AndroidService
service = AndroidService('Mentor Service', 'running')
service.start('service started')
self.service = service
# get any files into images directory
curdir = dirname(__file__)
list = glob(join(curdir, 'images', '*'))
Logger.debug("{}".format(list))
shuffle(list)
Logger.debug("{}".format(list))
for filename in list:
try:
# load the image
picture = Picture(source=filename, id=filename, rotation=randint(-30, 30))
# add to the main field
self.root.add_widget(picture)
except Exception as e:
Logger.exception('Pictures: Unable to load <%s>' % filename)
osc.init()
self.last_name = ""
osc.sendMsg('/say', ["La ap di Michele e' pronta", ], port=service_port)
return self.root
示例6: start_service
def start_service(self):
if _platform == 'android':
from android import AndroidService
service = AndroidService('WhiteNoise service', 'running')
service.start('service started')
self.service = service
else:
pass
示例7: build
def build(self):
global service
if platform == 'android':
from android import AndroidService
service = AndroidService('my service', 'running')
service.start('service started')
return NotificationDemo()
示例8: start_anontunnel_android
def start_anontunnel_android(self):
"""
Starts the anontunnel as an android service
"""
from android import AndroidService
service = AndroidService('Anonymous downloading Service', 'Anonymous tunnels are running...')
service.start('Anonymous tunnels service started')
self.service = service
示例9: build
def build(self):
if platform == 'android':
from android import AndroidService
service = AndroidService('pupy', 'running')
service.start('service started')
self.service = service
App.get_running_app().stop()
return Builder.load_string(kv)
示例10: start_service
def start_service(self):
if self.service is not None:
return
L.info("Trying to start service")
if platform == 'android':
from android import AndroidService
service = AndroidService('AndroidPark(ing)', 'en ejecución...')
service.start('service started')
self.service = service
示例11: start_new_service
def start_new_service(self, title=None, description=None):
if self.service is not None:
self.service.stop()
self.service = None
service = AndroidService(
title or self.service_title,
description or self.service_description)
service.start('service started')
self.service = service
示例12: UpdaterApp
class UpdaterApp(App):
def build(self):
print 'start android service'
from android import AndroidService
self.service = AndroidService('updater', 'running')
self.service.start('start')
return UpdaterUI(client=UpdateClient())
def on_pause(self):
return True
示例13: RemoteKivyApp
class RemoteKivyApp(App):
def build(self):
global app
app = self
self.service = AndroidService('Kivy Remote Shell',
'remote shell is running')
self.service.start('8000')
return MainScreen()
def quit_app(self):
self.service.stop()
self.stop()
示例14: FlashApp
class FlashApp(App):
def build(self):
self.root = Switch()
self.service = AndroidService('Kivy FlashLight', 'I haz a FlashLight!')
self.root.bind(active=self.toggle_flash)
return self.root
def toggle_flash(self, *args):
if self.root.active:
self.service.start()
else:
self.service.stop()
示例15: DjandroApp
class DjandroApp(App):
def build(self):
self.service = AndroidService('Django', 'Django is running')
open(LOGPATH, 'w').close() # Touch the logfile
self.running = False
self.logging = False
def toggle(self):
action = self.stop if self.running else self.start
self.running = not self.running
action()
self.root.ids['info'].text = "[color=#ff0000]Django is OFF[/color]"
if self.running:
self.root.ids['info'].text = "[color=#00ff00]Django is ON[/color]"
btn_text = 'Stop' if self.running else 'Start'
self.root.ids['btn'].text = btn_text + " Django"
def start(self):
self.service.start(LOGPATH)
self.start_logging()
def stop(self):
self.service.stop()
self.logging = False
self.running = False
def start_logging(self):
self.console = Thread(target=self.logger)
self.logging = True
self.console.start()
def logger(self):
label = self.root.ids['console']
log = open(LOGPATH, 'r')
label.text = log.read()
while self.logging:
log.seek(log.tell())
label.text += log.read()
sleep(0.2)
def on_pause(self):
if self.logging:
self.logging = False
self.console.join()
return True
def on_resume(self):
if self.running:
self.start_logging()