1、前提,連接上你的移動設(shè)備
2古徒、打開被測應(yīng)用app
3摆马、輸入adb命令臼闻,查看對應(yīng)的包名和activity
adb shell dumpsys window | findstr mCurrentFocus
adb shell dumpsys activity | findstr mFocusedActivity
樣張
mCurrentFocus=Window{4fa8d9a u0 com.xxx.xxxxx/com.xxx.xxxxx.main.ui.activity.MainActivity}
4、啟動對應(yīng)的包名和activity
adb shell am start -n com.xxx.xxxxx/com.xxx.xxxxx.main.ui.activity.MainActivity
5囤采、提示沒有權(quán)限
Android組件中有個 exported 屬性述呐,見官方文檔描述:
Flag indicating whether the given application component is available to other applications. If false, it can only be accessed by applications with its same user id (which usually means only by code in its own package). If true, it can be invoked by external entities, though which ones can do so may be controlled through permissions. The default value is false for activity, receiver, and service components that do not specify any intent filters; it is true for activity, receiver, and service components that do have intent filters (implying they expect to be invoked by others who do not know their particular component name) and for all content providers.
當(dāng)組件沒有intent-filter時exported 屬性默認(rèn)為false,此組件只能由本應(yīng)用用戶訪問蕉毯,配備了intent-filter后此值改變?yōu)閠rue乓搬,允許外部調(diào)用