AnsweredAssumed Answered

Sync array too AGOL

Question asked by mdondanville on Jul 31, 2017
Latest reply on Aug 15, 2017 by ANohe-esristaff

I am trying to make an offline app that records the GPS over time and when it is connected to Wifi, it takes all of the stored GPS points in the array and pushes them up to a featureservices online. I have experience with google maps API but this is my first application using ArcGIS Android SDK. Any help would be appreciated. 

 

public class OfflineGPS extends AbsRuntimePermission {

    ArrayList<Double> arrLat = new ArrayList<Double>();
    ArrayList<Double> arrLng = new ArrayList<Double>();

    ServiceFeatureTable sft;
    Portal portal;
    ListenableFuture<List<FeatureEditResult>> listListenableFuture;



    private static final int REQUEST_PERMISSION = 10;



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

..........      ..........

sft = new ServiceFeatureTable("https://services3.arcgis.com/fRxd0TMcSb4qCvqU/ArcGIS/rest/services/signsurvtracking/FeatureServer/0");
sft.addDoneLoadingListener(new Runnable() {
    @Override
    public void run() {
        Feature feature = sft.createFeature();
        feature.setGeometry(new Point(feature.getGeometry(arrLng), feature.getGeometry(arrLat),));
        feature.getAttributes().put("description", "DESCIPTION");
        sft.addFeatureAsync(feature).addDoneListener(new Runnable() {
            @Override
            public void run() {
                listListenableFuture = sft.applyEditsAsync();
                listListenableFuture.addDoneListener(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            for (FeatureEditResult featureEditResults : listListenableFuture.get()) {
                                Log.e("TEST", "Fetaure Edit Results");
                                Log.e("TEST", "ObjectID" +featureEditResults.getObjectId());
                                for (EditResult er : featureEditResults.getAttachmentResults()) {
                                    Log.e("TEST", "OBID" + er.getObjectId());
                                }
                            }
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        } catch (ExecutionException e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        });


    }
});

sft.loadAsync();






arrLng.clear();
arrLat.clear();

Outcomes