JobSchedulerCompat
JobSchedulerCompat copied to clipboard
Run Service only after run application
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,
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