I need to download some files in the background for which i used the job service . When i tried to deploy the application in android device version 7.0, an error occur saying "There was a problem while parsing the package". Here is my code
public class RegisterJobService:Activity
{
public static void SchelduleJob(Context context)
{
try
{
long REFRESH_INTERVAL = 90 * 1000;
JobInfo.Builder builder;
JobInfo jobInfo;
Java.Lang.Class javaClass = Java.Lang.Class.FromType(typeof(BackgroundAgentService));
ComponentName component = new ComponentName(context, javaClass);
builder = new JobInfo.Builder(0, component).SetPeriodic(REFRESH_INTERVAL);
jobInfo = builder.Build();
JobScheduler jobScheduler = (JobScheduler)context.GetSystemService(JobSchedulerService);
jobScheduler.Schedule(builder.Build());
}
catch (System.Exception ex)
{
}
}
}
//Code for Background Job Service
[Service(Name = "SampleTestApp.Helper.BackgroundAgent", Permission =
"android.permission.BIND_JOB_SERVICE")]
public class BackgroundAgentService : JobService
{
public override bool OnStartJob(JobParameters @params)
{
Log.Debug("BATest", "BackgroundAgentService-2/---------OnStartJob////clas");
return true;
}
public override bool OnStopJob(JobParameters @params)
{
//throw new NotImplementedException();
Log.Debug("BATest", "BackgroundAgentService/////++++++++++++OnStopJob/////2/////clas");
return true;
}
}
I found that when i remove the following code,there is no parser error but 'SchelduleJob' method goes to exception saying 'Java.Lang.IllegalArgumentException: No such service ComponentInfo'.
[Service(Name = "SampleTestApp.Helper.BackgroundAgent", Permission = "android.permission.BIND_JOB_SERVICE")]
Also i tried to add the permission in manifest file which is not working.
<application >
<service android:Name="SampleTestApp.Helper.BackgroundAgentService" android:enabled="true" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
</application>
Anyone have idea on this please?