应用程序被杀死后重新启动安卓服务



请,我更新了此文本以更好地了解我的问题。 我在我的应用程序中使用 Android 服务来启动本地通知,正如此处所述,在 Appcelerator Wiki 上。服务按预期运行良好,但如果从最近的应用程序托盘中删除应用程序或重新启动设备,服务将停止。

我想在应用程序被杀死后服务仍在运行或在重新启动设备后重新启动服务。我如何使用经典钛来做到这一点。

在我的应用程序的iOS版本中,我正在使用Ti.App.iOS.scheduleLocalNotification并且运行良好,即使在关闭和打开设备后也是如此。我希望在Android上以同样的方式工作。

谢谢你的任何帮助。

(对不起,我的英语不好(

看看这两个模块:

  • https://github.com/benbahrenburg/benCoding.AlarmManager
  • https://github.com/benbahrenburg/benCoding.Android.Tools/blob/master/documentation/bootreceiver.md

在那里,您可以使用 BootReceiver 在启动时重新启动,AlarmManager 应该会帮助完成该服务。

我知道这很旧,但你的问题出在tiapp上.xml你应该使用你的应用活动名称而不是".启动已完成活动",例如,如果您的应用程序是"我的测试应用程序",则活动名称应为"。我的测试应用活动">

<activity android:alwaysRetainTaskState="true"
android:configChanges="keyboardHidden|orientation"
android:label="BootCompleted"
android:launchMode="singleTop"
android:name=".BootCompletedActivity"
android:persistent="true" android:theme="@style/Theme.Titanium">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

最新更新