函数:runApp 运行应用

函数名称:运行应用

函数功能:打开一个应用程序

flag = runApp(bid)

必填

参数 类型 说明
bid string 应用程序的 Bundle ID

选填

返回值

返回值 类型 说明
flag number 0 应用启动成功
非 0 应用启动失败(7 表示应用不存在)

函数用例

打开 iOS 内置天气应用,然后退出

r = runApp("com.apple.weather")    --启动天气应用 
mSleep(10 * 1000);
if r == 0 then
    closeApp("com.apple.weather")    --退出天气应用,使用此函数后在后台仍可看到应用程序图标属正常现象,实际进程已不在后台
else
    nLog("启动失败")
end

注意事项

  • runApp 函数需要系统响应时间较长,注意做好延迟或判断

参考资料 Bundle ID 的获取方法

  • iOS 使用 iFile、爱思助手等软件可查看应用文件夹下的 Info.plist,其中的 CFBundleIdentifier 即为该应用的 Bundle ID。
Copyright 北京帮你玩科技有限公司 2024 all right reserved,powered by Gitbook该文章修订时间: 2025-03-04 15:43:41

results matching ""

    No results matching ""