Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

Run Service only after run application #35

Open
MansoorJafari opened this issue Dec 16, 2015 · 1 comment
Open

Run Service only after run application #35

MansoorJafari opened this issue Dec 16, 2015 · 1 comment

Comments

@MansoorJafari
Copy link

Dear Mr.evant
after set service to my application in api<21 service run only after run application and when I close app service don't run,But in api>21 service all of time run,
and
What is the difference between the two values
NETWORK_TYPE_UNMETERED
and
NETWORK_TYPE_ANY

Please give me an approach for fix this bug.

thank you,

@mkodekar
Copy link

Possible fix is like this but it is a big compromise i had to particularly had to do some workaround with the alarm manager and broadcast reciever

Here is once such example where i had to make three broadcast recievers for three different condition here is one of them

package com.emagic.newproject.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.emagic.newproject.service.LoadCategoryService;

/**

  • Created by mkodekar on 1/22/2016.
    */
    public class StartTaskLoadCategoriesPower extends BroadcastReceiver {
    @OverRide
    public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_POWER_CONNECTED.equals(intent.getAction())) {
    Toast.makeText(context, "Fecthing Data in Power Connection Mdoe", Toast.LENGTH_SHORT).show();
    Intent serviceIntent = new Intent(context, LoadCategoryService.class);
    context.startService(serviceIntent);
    }
    }
    }

and the manifest entry





Huge Compromise it is but effective

instead of the intent you can initialize the job here and see what it does

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants