posted by 네코냥이 2015. 3. 31. 15:10



-----


No need to use grep. ps in Android can filter by COMM value (last 15 characters of the package name in case of java app)

Let's say we want to check if com.android.phone is running:

adb shell ps m.android.phone
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
radio     1389  277   515960 33964 ffffffff 4024c270 S com.android.phone


-----


for (RunningAppProcessInfo runningProInfo : runningProcInfo) {

    int pid = runningProInfo.pid;

    Log.e(TAG+"-pid", ""+pid);

}


-----


http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html


RunningAppProcessInfo 
public intimportanceThe relative importance level that the system places on this process.
public intimportanceReasonCodeThe reason for importance, if any.
public ComponentNameimportanceReasonComponentFor the specified values of importanceReasonCode, this is the name of the component that is being used in this process.
public intimportanceReasonPidFor the specified values of importanceReasonCode, this is the process ID of the other process that is a client of this process.
public intlastTrimLevelLast memory trim level reported to the process: corresponds to the values supplied toComponentCallbacks2.onTrimMemory(int).
public intlruAn additional ordering within a particular importance category, providing finer-grained information about the relative utility of processes within a category.
public intpidThe pid of this process; 0 if none
public String[]pkgListAll packages that have been loaded into the process.
public StringprocessNameThe name of the process that this object is associated with
public intuidThe user id of this process.



---------



Is process name same as package name in android?




By default android takes the package name as the process name. But if you define process property in application tag in manifest file android:process="com.example.newprocessname" then the application will run with this name "com.example.newprocessname".

As for your questions,

Hope this answers your question!

shareimprove this answer



'JAVA > Android' 카테고리의 다른 글

다른 어플 실행  (0) 2015.04.01
어플 종료  (0) 2015.04.01
안드로이드 뷰 동적으로 마진주기  (0) 2015.03.15
브로드 캐스트 리시버 기본 사용예제.  (0) 2015.01.13
안드로이드 AIDL  (0) 2015.01.13