Select to view content in your preferred language

Sync array too AGOL

876
6
07-31-2017 11:19 AM
MatthewDondanville1
Occasional Contributor

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();
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
6 Replies
AlexanderNohe1
Honored Contributor

Is the sync operation working for you?

Are you having trouble with another type of operation?

0 Kudos
MatthewDondanville1
Occasional Contributor

I have checked online and have not gotten it to sync. I want to pass the array lat and long through the createpoint and pass it up to the featureservice online. 

0 Kudos
AlexanderNohe1
Honored Contributor

In order to add features offline so they can sync online, this is the route that I would take:

You would need a sync enabled feature service.

1) Create an offline geodatabase.

2) Store point features in that geodatabase as they are collected.

3) Periodically check that there is an active connection and start the geodatabase sync job. (You can use JobScheduler for this and to check other conditions to start the sync)

4) Sync happens.  (I would consider running in a foreground notification so you do not run into the Android system recycling your service / resources)

What it looks like you are doing above, is you are trying to add to an active online feature service without the offline mechanism set up.

I hope this helps!

0 Kudos
MatthewDondanville1
Occasional Contributor

I am new to ArcGIS development and only have limited Google Maps API knowledge but I will take a look. My goal is to not make the field workers sign in and download a database before they go out. Just write to the app and sync up at the end of the day only. Is there a way to write to any storage, JSON or Geodatabase, and push up to the feature service at the end of the day. I do not need attributes, just the point geometries. 


Ideally, I want to create a blank Geodatabase in the app on startup and write to it and have it write to a known featureservice on AGOL when we have internet.

Thank you!! 

0 Kudos
AlexanderNohe1
Honored Contributor

I don't believe sign in is required to sync with a geodatabase.

0 Kudos
AlexanderNohe1
Honored Contributor

I also believe that workflow should be possible if  you are only interested in storing location. You can go and iterate over the stored features and write them to the feature service individually at the end of the day.

0 Kudos