【问题标题】:Android BackGround service not works in Lollipop using start service [duplicate]Android BackGround 服务在使用启动服务的 Lollipop 中不起作用 [重复]
【发布时间】:2016-08-06 09:54:39
【问题描述】:

我有一个在后台运行的用于推送通知的 Android 应用服务。 它使用 startService() 调用意图;它在预版本中运行良好,但不适用于棒棒糖。我不知道为什么它不起作用(因为服务意图在棒棒糖中必须是明确的)但是当我试图让它明确的后台服务不起作用时。如何解决它。

这是调用服务的部分工作代码:

主活动

   Intent serviceIntent = new Intent("android.intent.action.START_SERVICE");
   this.startService(serviceIntent);

清单

 <service android:name=".MyService">
        <intent-filter>
            <action android:name="android.intent.action.START_SERVICE" />
            </intent-filter>
        </service>

【问题讨论】:

    标签: android android-intent android-service android-intentservice explicit-intent


    【解决方案1】:

    设置你的 packageName 我认为它的工作。

    intent.setPackage(this.getPackageName());
    

    【讨论】:

    • 没用......
    • 您想将您的谷歌库更新到较新的版本
    • 它是用于推送通知的应用程序,没有 gcm 之类的东西。但服务不会在棒棒糖的后台连续运行,但它可以工作。
    猜你喜欢
    • 2012-01-25
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 2013-11-20
    • 1970-01-01
    • 2015-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多