I'm running on android this
Command:
dumpsys activity activities | grep mFocusedApp
Output:
mFocusedApp=ActivityRecord{273535b u0 com.any.some/.app.AnyActivity t5595}
Expected:
com.any.some
I need the package name only Either by sed or another direct command
Edit (Copied from a comment to an answer; added to clarify that the resulting string shall be passed as an argument to commands.)
I need to restart the currently focused app so my idea was after grabbing the package name I will stop it by am stop and am start, example:
am stop com.any.some && am start com.any.some
echo mFocusedApp=ActivityRecord{273535b u0 com.any.some/.app.AnyActivity t5595} | cut -d\ -f3 | cut -d/ -f1yieldscom.any.somebut like I say, more sample output would make for a more robust solution.