Bug 59198 - Xamarin Android - JobInfo.TriggerContentUri has no constructor available
Summary: Xamarin Android - JobInfo.TriggerContentUri has no constructor available
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.4 (15.3)
Hardware: PC Windows
: --- blocker
Target Milestone: 15.4
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-09-03 14:06 UTC by master.d3v
Modified: 2017-10-13 12:38 UTC (History)
3 users (show)

Tags: 15.3I
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description master.d3v 2017-09-03 14:06:50 UTC
# Steps to reproduce
    JobInfo.Builder builder = new JobInfo.Builder(0, new ComponentName(context, serviceName));
    // Look for specific changes to images in the provider.
    // !!! Below no constructor exists : new JobInfo.TriggerContentUri(...)
    builder.AddTriggerContentUri(new JobInfo.TriggerContentUri(MediaStore.Images.Media.ExternalContentUri, TriggerContentUriFlags.NotifyForDescendants));
    // Also look for general reports of changes in the overall provider.
    //builder.addTriggerContentUri(new JobInfo.TriggerContentUri(MEDIA_URI, 0));
    var jobInfo = builder.Build();

My solution references Mono.Android 7.1, and targets Android 6.0 at minimum.

# Expected behavior
Android link: https://developer.android.com/topic/performance/background-optimization.html#media-broadcasts
I want to convert a simple code provided by google for android, allowing me to create a jobservice which triggers when a new media is created (source).

# Actual behavior
I can convert almost all without any problem, but it seems impossible to create a new TriggerContentUri, because no constructor exists.

# Supplemental info (logs, images, videos)

# Test environment (full version information)
Comment 1 Jon Douglas [MSFT] 2017-09-05 15:50:30 UTC
This looks like it is indeed missing. We need to expose a ctor similar to the following:

https://developer.android.com/reference/android/app/job/JobInfo.TriggerContentUri.html#JobInfo.TriggerContentUri(android.net.Uri, int)

It seems a question has been asked on Stack Overflow and was not answered(Same poster based on similar code):


This API was added in API level 24. The only constructor available that I see is:

      internal TriggerContentUri(IntPtr javaReference, JniHandleOwnership transfer)
        : base(javaReference, transfer)

The interesting part is that there is an existing method map:


Here's a quick decompilation of the android.jar:

public class JobInfo
  implements Parcelable
  public static final int BACKOFF_POLICY_EXPONENTIAL = 1;
  public static final int BACKOFF_POLICY_LINEAR = 0;
  public static final class TriggerContentUri
    implements Parcelable
    public TriggerContentUri(Uri uri, int flags)
      throw new RuntimeException("Stub!");

Thus I am marking this issue as CONFIRMED.
Comment 2 Jonathan Pryor 2017-09-28 19:52:54 UTC
This appears to be fixed in d15-4.


> $ monodis --method /Library/Frameworks/Xamarin.Android.framework/Versions/7.4.0-19/lib/xbuild-frameworks/MonoAndroid/v7.0/Mono.Android.dll
> ...
> ########## .TriggerContentUri
> 132180: instance default void '.ctor' (native int javaReference, valuetype Android.Runtime.JniHandleOwnership transfer)  (param: 141252 impl_flags: cil managed )


> $ monodis --method /Library/Frameworks/Xamarin.Android.framework/Versions/8.0.0-13/lib/xbuild-frameworks/MonoAndroid/v7.0/Mono.Android.dll
> ...
> ########## .TriggerContentUri
> 129757: instance default void '.ctor' (native int javaReference, valuetype Android.Runtime.JniHandleOwnership transfer)  (param: 139882 impl_flags: cil managed )
> 129758: instance default void '.ctor' (class Android.Net.Uri uri, valuetype Android.App.Job.TriggerContentUriFlags 'flags')  (param: 139884 impl_flags: cil managed )
Comment 3 Kumar Motwani 2017-10-13 12:38:03 UTC
As per our understanding user could not found contructor for class TriggerContentUri using 15.3 version of XVS.

We have verified the defect on latest 15.4 VS 2017 build and were able succesfuly created the instance of TriggerContentUri by invoking constructor of TriggerContentUri

Our findings in the build version VS 15.4
We were able to locate the class TriggerContentUri at Android.App.Job.JobInfo.TriggerContentUri
We were found the constructor signature as -
[Register(".ctor", "(Landroid/net/Uri;I)V", "")]
public TriggerContentUri(Net.Uri uri, [GeneratedEnum] TriggerContentUriFlags flags);
We succesfuly created the instance of TriggerContentUri by invoking constructor of TriggerContentUri as below-
   var uri = Android.Net.Uri.Parse("http://google.com");
   var job = new JobInfo.TriggerContentUri(uri, TriggerContentUriFlags.NotifyForDescendants); 

Note- While trying to reproduce the issue on 15.3.3 VS2017 build. Our findings is there is no class definition found for TriggerContentUri at Android.App.Job.JobInfo. This is overall issue which customer have reported it.

Defect Fixed on 15.4 VS 2017
Xamarin (54942a671)
Xamarin.Android SDK (HEAD/7a6a056e8)
Xamarin.iOS and Xamarin.Mac SDK (9a9f054)


Device: Nexus 6P OS 8.0