You can specify a fixed log directory where log files are stored for analysis and troubleshooting.
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
The preceding permissions are dangerous permissions. You need to dynamically apply for these permissions (according to dangerous permission requirements in Android 6.0 or later).
You can pass the log file path and related parameter settings using the LogConfig object, and then call setLogConfig() to enable log recording.
Java SettingsClient settingsClient = LocationServices.getSettingsClient(this);
Kotlin var settingsClient = LocationServices.getSettingsClient(this)
Java String filePath = getApplicationContext().getFilesDir().getAbsolutePath() + "/log"; LogConfig logConfig = new LogConfig(); // Set the path for storing log files. logConfig.setLogPath(filePath);
Kotlin val filePath = applicationContext.filesDir.absolutePath + "/log" val logConfig = LogConfig() // Set the path for storing log files. logConfig.setLogPath(filePath)
Java settingsClient.setLogConfig(logConfig).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(Exception e) { // TODO: If no error information is returned, log recording is enabled successfully. } });
Kotlin settingsClient!!.setLogConfig(logConfig).addOnFailureListener { // TODO: If no error information is returned, log recording is enabled successfully. }
To change the path for storing log files after enabling log recording, stop the app process for which log recording has been enabled, pass a new path for storing log files, and enable log recording. When you stop the app process, the log recording function will be disabled and logs will no longer be recorded.