-3

I created an android application in java in android studio and I need to export some data for validation purpose. I would like to save a 2 dimensiohs integer array in a .csv or .txt file in my computer or in my phone when I am running the application (I don't Have SD card slot in my phone).

Do you have any Idea ?

To go further, I will love to export the data in real time to my computer and to plot the 2 dimension array with python or Bash.. Is it possible ?

Thanks a lot !

Rob
  • 14,746
  • 28
  • 47
  • 65
Yoann Rey
  • 5
  • 2
  • can you explain this in detail? – Ritu Suman Mohanty Aug 13 '20 at 13:49
  • I just Have an Idea, Maybe I can Parse the android studio Logcat with a bash or python script ? Does someone knows how to do it.. – Yoann Rey Aug 13 '20 at 13:49
  • @RituSumanMohanty Oh sorry, I will try : I have made an android application and while the device is connected to my PC for testing purpose I would like to see some informations in my computer. The information I am trying to see in my computer is the time of flight sensor Data. These data are a depth map (240*180 pixels) (x,y,z) stocked into a int[x][y]. As you can imagine it is difficult to see it in the logcat, and I would like to plot it in 3dimensions, if I can do it in real time it will be perfect :) ! – Yoann Rey Aug 13 '20 at 13:58
  • I never tried these things.so cant say anything – Ritu Suman Mohanty Aug 13 '20 at 16:17
  • Please add these details to your Question, as it seems to be a little too broad right now. It should preferable be a practical programming problem. – Scratte Aug 13 '20 at 22:15

1 Answers1

0

You can run adb logcat in console and parse live data in any way convenient for you: https://developer.android.com/studio/command-line/logcat

Example (Windows PowerShell):

 & $ENV:LOCALAPPDATA\Android\Sdk\platform-tools\adb.exe logcat -s MyTag

In app (Java):

Log.d("MyTag", "My debug data");

Getting live logcat data in Python (Windows):

import os, subprocess
cmd = os.getenv("LOCALAPPDATA") + r"\Android\Sdk\platform-tools\adb.exe logcat -s MyTag"
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1)
for line in iter(p.stdout.readline, b""):
    print(line)
p.stdout.close()
p.wait()

Tip: you can also run debugging via local Wi-Fi network without connecting the device with a cable to your PC: How can I connect to Android with ADB over TCP?

Mikhail
  • 2,612
  • 3
  • 22
  • 37
  • Thanks a lot, it worked well! Unfortunately for my purpose I have some real time problems, this solution is too slow, I will need to find another way ! – Yoann Rey Aug 17 '20 at 07:58