Skip to content
Sathya Prasad edited this page Jun 3, 2016 · 8 revisions

All the examples below needs this import

import ArcGIS.AppFramework 1.0

Check if device is offline

 property bool isOnline: true
  Connections {
        target: AppFramework.network
        onIsOnlineChanged: {
            isOnline = AppFramework.network.isOnline
        }
    }

//----- OR ------
property bool isOnline: AppFramework.network.isOnline

Enable network proxy via code

Component.onCompleted: {
        console.log("########### Start Page ###########");
        AppFramework.network.proxy.url = "http://127.0.0.1:8888";
        AppFramework.network.proxy.type = NetworkProxy.HttpProxy;
        //If using Runtime
        ArcGISRuntime.setupProxy("http://127.0.0.1:8888"); 
        
        //optional
        IdentityManager.ignoreSslErrors = true;
    }

Read from local file (example: JSON file)

 FileFolder {
        id: appFolder
        path: app.folder.path

        //read file immediately or you can access this from other events
        Component.onCompleted: {
            console.log("file folder ready: ", folderName);
            var res = readJsonFile("appinfo.json");
            console.log(JSON.stringify(res));
        }
    }

//alt: Read file when Button is clicked
Button {
 text: "Read File"
 onClicked: {
   var res = appFolder.readJsonFile("appinfo.json");
   //test the results
   console.log(JSON.stringify(res));
 }
}

Read local html file and display it

ScrollView {
            id: scrollView

            Layout.fillWidth: true
            Layout.fillHeight: true

            Text {
                width: scrollView.width
                text: app.folder.readTextFile("test.html")
                textFormat: Text.RichText
                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
            }
        }

In this case the file "test.html" is at the app root level along with other files such as "appinfo.json" and "iteminfo.json"