Development record of developer who study hard everyday.

, ,

How to watch CPU usage using adb in android

 How to watch CPU usage using adb in android


1. Show CPU usage respectively in apps.

adb shell top -n 1 -s cpu


->details about top options

-m num : Maximum number of processes to display

-n num : Updates to show before exiting

-d num : Seconds to wait between updates

-s col : Column to sort by (cpu, vss, rss, thr)

-H : Show threads instead of prcesses

-h : Display this help screen


2. Show CPU usage in specific app

adb shell top -n 60 -d 1 | FINDSTR <package name>

This command shows CPU usages during 60 seconds by 1 second.





Share:
Read More
,

(Sloved) Android Studio APK install error: "local path doesn't exist"

 


I encounter the error "Android Studio APK install error: "local path doesn't exist" while building android source.

The solution is

  • Go to your project directory.In that directory search for .apk file....
  • You will find a apk with name of your project+debug-unalighned.apk.
  • Open .iml file insideyour project folder that contain project source directory.
  • Open and add write <option name="APK_PATH" value="/build/apk/(apk file name that was found earlier with apk extension)" /> inside <configration> <configration/> tags.
  • Now go and run your project...


Share:
Read More
, ,

How to separate string data by sentences

How to separate string data by sentences

안드로이드 블로그

When I am developing android app using Kotlin, I had to separate string data by one sentence.

There might be so many solutions, but I want short code using regular expression.

My solution is

1
2
3
4
5
6
7
8
9
10
fun main() {
    val text = "감오리는 사막이나 농촌지역에서 주로 발견되며, 땅속에 다닐 수 있는 능력이 있어 땅속에서 먹이를 찾기 위해 파묻기를 합니다. 감오리는 매우 활발한 동물로 매일 새로운 먹이를 찾으며 유혈자로 알려져 있습니다. 감오리는 오래 살아 가는 동물이며, 50년에서 70년까지 살 수 있습니다. 감오리의 수명은 종류에 따라 다르지만, 평균적으로 10년 정도입니다. 감오리는 인간과 친밀한 관계를 맺을 수 있는 동물로, 그들은 상호 의존적인 관계에서 존재합니다."
 
    val pattern = Regex("[^.!?]+[.!?]")        
    val matches = pattern.findAll(text)
 
    val sentences = matches.map { it.value.trim() }.toList()
 
    println(sentences)
}
cs


Share:
Read More
,

Useful ADB shortkeys

Useful ADB shortkeys



Android Debug Bridge(ADB) is CLI tool which communicate with device.
Android SDK Platform includes ADB package.


- Move directory

adb shell cd "path"


- Reboot device

adb reboot


- Show connected devices

adb devices


- Start server

adb start-server


- Kill server

adb kill-server


- Exectue command to specific device

adb -s "example device name" "example command"


- Connect wifi (Available Under Android 10)

adb connect "example device ip address"


- Move file to device

adb push "example local file" "example device directory"


- Take device file to local

adb pull "example device file" "example local directory"


- Get writing and reading permission

adb shell mount -o remount,rw /system


- Turn on wifi

adb shell svc wifi enable


-Turn off wifi

adb shell svc wifi disable


- Turn on mobile data

adb shell svc data enable


- Turn off mobile data

adb shell svc data disable


- Change device's date

1) adb shell "su 0 toybox date 042523592021.59"
(toybox date use MMDDhhmm[[CC]YY][.ss] format)

2) adb shell "su 0 toolbox date -s 20210425.235959"
(toolbox date use YYYYMMDD.HHmmss format)


- Symbolic link

adb shell ln -sf "example original file" "example target file"


- Show system property list

adb shell getprop


- Start activity

adb shell am start -a android.intent.action.MAIN -n "example/package/activity_name"


- Start service

adb shell am startservice -n "example/package/service_name"


- Start broadcast

adb shell am broadcast -a "example broadcast name"


- Start Broadcast extra

1) adb shell am broadcast -a $(example_action_name) -es ${example_extra_key} ${example_extra_string_value}

2) adb shell am broadcast -a $(example_action_name) -ez ${example_extra_key} $(extra_boolean_value)

3) adb shell am broadcast -a $(example_action_name) -ei $(example_extra_key) $(example_extra_int_value)


- Verify specific package's PID

adb shell pidof "example package name"


-Kill Process

adb shell am force-stop "example package name"
adb shell kill -9 PID (Available only if root)


- Show installed packages

adb shell cmd package list packages


- Find package's path

adb shell pm path "example package name"


- Screen capture

adb shell screencap -p /sdcard/Download/"example file name"
adb pull /sdcard/Download/"example file name" "local directory"


- Remove file

adb shell rm "example file"


- Remove directory

adb shell -r "example file"





Share:
Read More
,

리눅스 파티션 역할

리눅스 파티션별 역할

linux_information_blog


/ : 루트 파티션

/bin : 기본 명령어가 들어있음

/sbin : 시스템 관리용 명령어가 들어있음

/etc : 시스템 환경설정과 관련된 파일이 들어있음

/boot : 부팅 커널이 저장됨

/media : 외부 장치를 마운트하기 위해 제공됨

/usr : 응용프로그램이 주로 저장됨

/lib : 프로그램의 라이브러리가 저장됨

/dev : 장치 파일들이 저장됨

/proc : 시스템의 프로세서 정보, 프로그램 정보, 하드웨어 정보 등이 들어있음

/tmp : 임시파일이 저장됨

/var : 로그, 캐시 파일 등이 저장됨

/root : 시스템 관리자인 root의 홈 디렉터리

/home : 사용자별 공간

/lost+found : 파일 시스템 복구를 위한 디렉터리

swap 파티션 : RAM 부족 시 사용되는 공간


Share:
Read More