Skip to content

Intent API

The Network Survey Intent API allows external applications to interact with the Network Survey app. By sending Android intents with specific actions and extras, you can control various aspects of Network Survey’s functionality, such as:

  • Starting and stopping network surveys
  • Configuring logging options (cellular, Wi-Fi, etc.)
  • Setting up MQTT connections for real-time data streaming

This API is designed to enable integration between your application and Network Survey, enabling 3rd party apps to control the basic functions of Network Survey.

To use the Network Survey Intent API, you need to create an Intent object with the following action and component:

Action: com.craxiom.networksurvey.START_SURVEY or com.craxiom.networksurvey.STOP_SURVEY

Component:

  • Package: com.craxiom.networksurvey
  • Service: com.craxiom.networksurvey.services.NetworkSurveyService

The following extras can be set on an Intent to configure Network Survey’s behavior:

Extra NameTypeDescriptionExample Value
cellular_file_loggingbooleanIf true, cellular file logging will be enabledtrue
wifi_file_loggingbooleanIf true, Wi-Fi file logging will be enabledtrue
bluetooth_file_loggingbooleanIf true, Bluetooth file logging will be enabledtrue
gnss_file_loggingbooleanIf true, GNSS file logging will be enabledtrue
cdr_file_loggingbooleanIf true, call detail record file logging will be enabledtrue
mqtt_config_jsonstring (JSON)A JSON string containing MQTT connection configurationSee below

The mqtt_config_json extra value is a JSON string. Following is an example showing all the values that can be set in the JSON object:

{
"mqtt_host": "mqtt.example.com",
"mqtt_port": 8883,
"mqtt_tls": true,
"mqtt_client": "aclient",
"mqtt_username": "auser",
"mqtt_password": "apassword",
"mqtt_topic_prefix": "my/custom/topic/path/",
"cellular_stream_enabled": true,
"wifi_stream_enabled": true,
"bluetooth_stream_enabled": true,
"gnss_stream_enabled": true,
"device_status_stream_enabled": true
}

Required fields:

  • mqtt_host
  • mqtt_port
  • mqtt_tls
  • mqtt_client

All other fields are optional.

Intent startNetworkSurveyIntent = new Intent("com.craxiom.networksurvey.START_SURVEY");
// Specify which logging to enable
startNetworkSurveyIntent.putExtra("cellular_file_logging", true);
startNetworkSurveyIntent.putExtra("wifi_file_logging", true);
// Specify NS as the component
startNetworkSurveyIntent.setComponent(new ComponentName(
"com.craxiom.networksurvey",
"com.craxiom.networksurvey.services.NetworkSurveyService"
));
// Start the NS Service
context.startForegroundService(startNetworkSurveyIntent);

Start Network Survey with MQTT and Logging

Section titled “Start Network Survey with MQTT and Logging”
Intent startNetworkSurveyIntent = new Intent("com.craxiom.networksurvey.START_SURVEY");
// Specify which logging to enable
startNetworkSurveyIntent.putExtra("cellular_file_logging", true);
startNetworkSurveyIntent.putExtra("wifi_file_logging", true);
// MQTT is configured via a JSON string
String mqttConfigJsonString = "{\"mqtt_host\": \"mqtt.example.com\", " +
"\"mqtt_port\": 8883, " +
"\"mqtt_tls\": true, " +
"\"mqtt_client\": \"aclient\", " +
"\"mqtt_username\": \"auser\", " +
"\"mqtt_password\": \"apassword\", " +
"\"cellular_stream_enabled\": true, " +
"\"wifi_stream_enabled\": true, " +
"\"device_status_stream_enabled\": true " +
"}";
startNetworkSurveyIntent.putExtra("mqtt_config_json", mqttConfigJsonString);
// Specify NS as the component
startNetworkSurveyIntent.setComponent(new ComponentName(
"com.craxiom.networksurvey",
"com.craxiom.networksurvey.services.NetworkSurveyService"
));
// Start the NS Service
context.startForegroundService(startNetworkSurveyIntent);
Intent stopNetworkSurveyIntent = new Intent("com.craxiom.networksurvey.STOP_SURVEY");
// Specify the component
stopNetworkSurveyIntent.setComponent(new ComponentName(
"com.craxiom.networksurvey",
"com.craxiom.networksurvey.services.NetworkSurveyService"
));
// Start the service to stop it
context.startForegroundService(stopNetworkSurveyIntent);