0

I want to reset some alarm that starts a job scheduler after rebooting the phone, but this didn't happened so I wanted to know if BOOT_COMPLETE was received in my application, I'm testing like this while phone is connected to adb I restart phone so my phone is disconnected from adb and it shows in log, and I no longer see logs, how can I reconnect or able to see logs, is there adb command? to see logs of BOOT_COMPLETE broadcast, is there any command to connect adb at runtime while application is running?

blackkara
  • 4,900
  • 4
  • 28
  • 58
blackHawk
  • 6,047
  • 13
  • 57
  • 100
  • What about [`adb wait-for-device'](https://developer.android.com/studio/command-line/adb.html#issuingcommands) which blocks until device is online? – Onik Jul 21 '17 at 21:59

1 Answers1

0

First make sure that you can run "adb" by: use combination of Window + R > type "adb shell". It look like below

adb shell

1.Open text editor such as Notepad, Notepad++, ...

2.Copy and paste below text

@echo OFF
:a
adb logcat -s "YOURTAG"
goto a:

Replace YOURTAG text by your LogTag.

For example, in your code

Log.d("MyLogTag","what you want to log");

Then

@echo OFF
:a
adb logcat -s "MyLogTag"
goto a:

3.Save it as log.bat (If you cannot do this, First save it as log.txt, then rename this file as log.bat

4.Restart phone. While phone is restarting, open this file by double click and wait

Then you can see the logs from your application

LDQ
  • 16
  • 2
  • Replace YOURTAG by your application log tag. For example, in your code: Log.d("Test1", "onReceive boot completed"), so you use: adb logcat -s "Test1" – LDQ Jul 21 '17 at 05:35
  • could you send me any link which has more detail about this or any keyword for searching, I'm unable to understand its first time I'm hearing these words – blackHawk Jul 21 '17 at 05:37
  • please try to read it: https://stackoverflow.com/questions/7537419/how-to-filter-android-logcat-by-application. – LDQ Jul 21 '17 at 05:41
  • I understood this thing, but I'm unable to understand "Save into .bat file (if you are using Window)" – blackHawk Jul 21 '17 at 05:57
  • Could you tell me step by step a more detailed answer? – blackHawk Jul 21 '17 at 08:52
  • I edit something to make it clear. Hope it becomes easier to understand – LDQ Jul 21 '17 at 10:09
  • I added adb path to environment variables and able to run command, in my application for all my logs I used tag "MainActivity" so I modified bat file like this and saved to desktop @echo OFF :a adb logcat -s "MainActivity" goto a: – blackHawk Jul 21 '17 at 13:54
  • now when I'm running its just two lines begining of system and beginning of main and nothing else, will I able to see all my application log from this method? – blackHawk Jul 21 '17 at 13:55
  • I guess my Boot_Complete broadcast is not working, because in broadcast receiver class I added log but it was not visible – blackHawk Jul 21 '17 at 15:13