Offline Map
In order to save traffic, offline maps of a certain province and city can be downloaded to the SD card of the mobile phone, and the map service can be freely used without a network connection.
The location where the directory is initialized for the application, for example:
// mAppPath: the location where the offline map is stored
String mAppPath = Environment.getExternalStorageDirectory().getPath()+"/navinfo/app";
NativeEnvParams params = new NativeEnvParams(mAppPath, appName, mDensityDpi, key, this);
NativeEnv.init(getApplicationContext(), params);
[Navinfo Navigation SDK for Android] The offline data of the map is a data application without network, which saves users traffic and reduces the cost of use. The offline data store is packaged to implement automatic loading of offline lists, data downloads, breakpoint downloads, upgrades, and deletions.
Example is as follows:
// Initialize the data, add data load callback
OfflineDataStoreManager.getInstance().initData(this);
// data loading callback
@Override
public void onDataSuccess(DatastoreItem[] datastoreItems) {
// Data loaded successfully
progressBar.setVisibility(View.GONE);
this.datastoreItems = datastoreItems;
if (datastoreItems != null) {
// Set the listView data source
DownloadAdapter downloadAdapter = new DownloadAdapter(this, datastoreItems);
mListView.setAdapter(downloadAdapter);
}
}
@Override
public void onDataFailure() {
// data loading failed
progressBar.setVisibility(View.GONE);
Toast.makeText(this, "refresh faile", Toast.LENGTH_SHORT).show();
}
@Override
public void onDataCancle() {
// data loading canceled
progressBar.setVisibility(View.GONE);
Toast.makeText(this, "refresh cancel", Toast.LENGTH_SHORT).show();
}
Note: The offline data function implementation code reference SDK Demo.
