I'm migrating an Android application that used the ESRI SDK 10.2.8 into SDK 100.6.
In order to add new features, the application needs to use a custom service whose main parameter is the Feature in JSON format.
In the old version, the new element to insert was a Graphic and that object had the .toJson() method. In the new SDK the Grpahic object still exists, but it is not used for the same and the method to transform it into a JSON is gone. I have built an object Feature with the new element I want to add, but I have no idea how to convert that to JSON.
What I have tried so far:
ArcGISFeature f <SPAN class="operator token">=</SPAN> <SPAN class="token function">objectToFeature</SPAN><SPAN class="punctuation token">(</SPAN>myObject<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">try</SPAN> <SPAN class="punctuation token">{</SPAN>
FeatureCollection fc <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureCollection</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
FeatureCollectionTable testTable <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureCollectionTable</SPAN><SPAN class="punctuation token">(</SPAN>f<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getFeatureTable</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">getFields</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> GeometryType<SPAN class="punctuation token">.</SPAN>UNKNOWN<SPAN class="punctuation token">,</SPAN> SpatialReferences<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getWgs84</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
ListenableFuture future <SPAN class="operator token">=</SPAN> testTable<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addFeatureAsync</SPAN><SPAN class="punctuation token">(</SPAN>f<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
future<SPAN class="punctuation token">.</SPAN><SPAN class="token function">get</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
fc<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getTables</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>testTable<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
fc<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loadAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
fc<SPAN class="punctuation token">.</SPAN><SPAN class="token function">toJson</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">catch</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token class-name">Exception</SPAN> ex<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
String c <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I thought this was the way to go, but the "addFeatureAsync" is not working and throwing the error:
com.esri.arcgisruntime.ArcGISRuntimeException: Abort due to constraint violation<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
No idea which constraint it is talking about.
Is there an easier way (or another way) to obtain the JSON of the new Feature I have created?
Thanks for any help!!