Adi
Adi

Reputation: 400

Android BackGround service not works in Lollipop using start service

I have an android app service for pushing notification which run in the background. It invokes the intent using startService(); It works fine in pre-versions but it does not work on lollipop. I am not aware of Why it is not works (Because service intents must be explicit in lollipop) but when i" trying to make it explecit background service not works.How to resolve it.

Here is part of working code to invoke service:

MainActivity

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

Manifest

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

Upvotes: 0

Views: 1120

Answers (1)

Shailendra Kushwah
Shailendra Kushwah

Reputation: 415

Set your packageName i think its work.

intent.setPackage(this.getPackageName());

Upvotes: 0

Related Questions