【问题标题】:How to start an android service when the system boots up?系统启动时如何启动android服务?
【发布时间】:2017-07-09 20:47:19
【问题描述】:

我想在系统启动时启动 Android 服务。我已经在这里阅读了如何启动应用程序:http://dannywind.nl/auto-start-delphi-xe5-android-app-after-boot/ 但我不想启动应用程序而是服务。

怎么做? 我在 delphi Berlin 下

【问题讨论】:

  • 与应用程序一样,只需启动服务即可,例如第一个答案,此处:stackoverflow.com/questions/2784441/…
  • 您必须实现一个处理BOOT_COMPLETED 广播的BroadcastReceiver,然后才能运行该服务。在 Delphi 中实现BroadcastReceiver 并非不可能,但也不是微不足道的。环顾四周,有在线教程解释了如何做到这一点。
  • 好的,谢谢,我会环顾四周,接缝他们是无法逃脱为此构建自定义罐子的

标签: delphi android-service firemonkey


【解决方案1】:

如果您不想创建自定义 jar/java,我就是这样做的:

您只需要使用以下内容更新您的 android 清单:

  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

  <receiver android:name="com.alcinoe.content.ALStartServiceBroadcastReceiver">  
    <intent-filter>  
      <action android:name="android.intent.action.BOOT_COMPLETED" />  
    </intent-filter>  
  </receiver>
  <meta-data android:name="com.alcinoe.startServiceName" android:value="com.embarcadero.services.myService"/>   

并添加 alcinoe.jar (https://svn.code.sf.net/p/alcinoe/code/)

所有你需要做的:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-03
    相关资源
    最近更新 更多