android/src/com/mapswithme/util/Utils.java
public static String saveLogToFile()
  {
    String fullName = MwmApplication.get().getDataStoragePath() + "log.txt";
    File file = new File(fullName);
    InputStreamReader reader = null;
    FileWriter writer = null;
    try
    {
      writer = new FileWriter(file);
      writer.write("Android version: " + Build.VERSION.SDK_INT + "\n");
      writer.write("Device: " + getDeviceModel() + "\n");
      writer.write("App version: " + BuildConfig.APPLICATION_ID + " " + BuildConfig.VERSION_NAME + "\n");
      writer.write("Locale : " + Locale.getDefault());
      writer.write("\nNetworks : ");
      final ConnectivityManager manager = (ConnectivityManager) MwmApplication.get().getSystemService(Context.CONNECTIVITY_SERVICE);
      for (NetworkInfo info : manager.getAllNetworkInfo())
        writer.write(info.toString());
      writer.write("\n\n");

      String cmd = "logcat -d -v time";
      Process process = Runtime.getRuntime().exec(cmd);
      reader = new InputStreamReader(process.getInputStream());
      char[] buffer = new char[10000];
      do
      {
        int n = reader.read(buffer, 0, buffer.length);
        if (n == -1)
          break;
        writer.write(buffer, 0, n);
      } while (true);

      reader.close();
      writer.close();
    } catch (IOException e)
    {
      closeStream(writer);
      closeStream(reader);

      return null;
    }

    return fullName;
  }
/**
   * Stores logcat output of the application to a file on primary external storage.
   *
   * @return name of the logfile. May be null in case of error.
   */
Stores logcat output of the application to a file on primary external storage.
@return name of the logfile. May be null in case of error.
Stores logcat output of the application to a file on primary external storage . @return name of the logfile . May be null in case of error .
public static String saveLogToFile()
  {
    String fullName = MwmApplication.get().getDataStoragePath() + "log.txt";
    File file = new File(fullName);
    InputStreamReader reader = null;
    FileWriter writer = null;
    try
    {
      writer = new FileWriter(file);
      writer.write("Android version: " + Build.VERSION.SDK_INT + "\n");
      writer.write("Device: " + getDeviceModel() + "\n");
      writer.write("App version: " + BuildConfig.APPLICATION_ID + " " + BuildConfig.VERSION_NAME + "\n");
      writer.write("Locale : " + Locale.getDefault());
      writer.write("\nNetworks : ");
      final ConnectivityManager manager = (ConnectivityManager) MwmApplication.get().getSystemService(Context.CONNECTIVITY_SERVICE);
      for (NetworkInfo info : manager.getAllNetworkInfo())
        writer.write(info.toString());
      writer.write("\n\n");
      String cmd = "logcat -d -v time";
      Process process = Runtime.getRuntime().exec(cmd);
      reader = new InputStreamReader(process.getInputStream());
      char[] buffer = new char[10000];
      do
      {
        int n = reader.read(buffer, 0, buffer.length);
        if (n == -1)
          break;
        writer.write(buffer, 0, n);
      } while (true);
      reader.close();
      writer.close();
    } catch (IOException e)
    {
      closeStream(writer);
      closeStream(reader);
      return null;
    }
    return fullName;
  }
public static String saveLogToFile ( ) { String fullName = MwmApplication . get ( ) . getDataStoragePath ( ) + "log.txt" ; File file = new File ( fullName ) ; InputStreamReader reader = null ; FileWriter writer = null ; try { writer = new FileWriter ( file ) ; writer . write ( "Android version: " + Build . VERSION . SDK_INT + "\n" ) ; writer . write ( "Device: " + getDeviceModel ( ) + "\n" ) ; writer . write ( "App version: " + BuildConfig . APPLICATION_ID + " " + BuildConfig . VERSION_NAME + "\n" ) ; writer . write ( "Locale : " + Locale . getDefault ( ) ) ; writer . write ( "\nNetworks : " ) ; final ConnectivityManager manager = ( ConnectivityManager ) MwmApplication . get ( ) . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; for ( NetworkInfo info : manager . getAllNetworkInfo ( ) ) writer . write ( info . toString ( ) ) ; writer . write ( "\n\n" ) ; String cmd = "logcat -d -v time" ; Process process = Runtime . getRuntime ( ) . exec ( cmd ) ; reader = new InputStreamReader ( process . getInputStream ( ) ) ; char [ ] buffer = new char [ 10000 ] ; do { int n = reader . read ( buffer , 0 , buffer . length ) ; if ( n == - 1 ) break ; writer . write ( buffer , 0 , n ) ; } while ( true ) ; reader . close ( ) ; writer . close ( ) ; } catch ( IOException e ) { closeStream ( writer ) ; closeStream ( reader ) ; return null ; } return fullName ; }
Stores logcat output of the application to a file on primary external storage.
Stores logcat output of the application to a file on primary external storage .