脚本-外部跳转打开应用对应页面

1、方式:python+adb命令

2、实现

 1 # -*- coding:utf-8 -*
 2 import os
 3 
 4 event_intent = {
 5     'video': 'video?vid=**'
 6     'living': 'live?uid=**'
 7 }
 8 11 
12 # 退出app
13 kill_app = 'adb shell am force-stop <package_name>'
14 # 启动app
15 start_app = 'adb shell "am start \'<uri>\'"'
16 
17 
18 for value in event_intent:
19     for bt in backtype:
20         cmd = 'adb shell "am start \'<uri>%s\'"' \
21               % (event_intent[value])
22         # print(cmd)
23         if bt == 1:
24             os.system('adb shell am start -n com.android.settings/com.android.settings.Settings ')
25             os.system('adb shell sleep 5')
26             os.system(cmd)
27             os.system('adb shell sleep 15')
28             os.system(kill_app)
29             os.system('adb shell sleep 5')
30             os.system('adb shell am force-stop com.android.settings')
31         else:
32             os.system(cmd)
33             os.system('adb shell sleep 15')
34             os.system(kill_app)

3、注意:善用sleep,避免手机反应不过导致运行失败

 

posted @ 2021-05-18 17:55  SpriteGirl  阅读(284)  评论(0)    收藏  举报