重新启动从PhoneGap的设备 [英] Reboot a device from phonegap

查看:387
本文介绍了重新启动从PhoneGap的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来重新启动设备用的PhoneGap /科尔多瓦?我将如何去这样做呢?我想这可能无法在iPad / iPhone,但是,那将是机器人。

Is there a way to reboot a device with phonegap/cordova? How would I go about doing this? I think it may not be possible on an ipad/iphone but it would be on androids.

推荐答案

首先基本上它不能这样做,除非你的设备是植根/ jailbreaken(取决于我们在谈论的 Android版 iOS版)。

First basically it can't be done unless your device is rooted/jailbreaken (depending are we talking about Android or iOS).

现在来,即使你已经植根/ jailbreaken设备,您将无法做有趣的部分,除非你可以做一些的Java / *的目标C 的*发展

Now comes the fun part even if you have rooted/jailbreaken device you will not be able to do that unless you can do some Java/*Objective C* development.

基本上的PhoneGap 插件,不只是因为通常不需要此功能,除非你正在做的与您的手机上的东西基本级别存在。 但是如果您有足够的知识,你可以通过你自己去做。 的PhoneGap 插件可以创建非常简单,你可以找到在这个多个<一个href=\"http://docs.phonegap.com/en/2.7.0/guide_plugin-development_index.md.html\">tutorial.你想要做的是创建一个简单的插件,将执行的Java / *的目标C 的当你需要它* code。

Basically Phonegap plugin don't exist simply because this functionality is usually not needed unless you are doing something with your phone on a basic level. But if you have enough knowledge you can do it by your self. Phonegap plugin can be created very easy, and you can find more in this tutorial. What you want to do is create a simple plugin that will execute Java/*Objective C* code when you need it.

try {
    Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot" });
    proc.waitFor();
} catch (Exception ex) {
    Log.i(TAG, "Could not reboot", ex);
}

的iOS / Objective C的例子

不幸的是我没有与iOS上的这个功能,很多经验,所以你需要信任这个 答案

iOS/Objective C example

Unfortunately I don't have that much experience with this functionality on iOS so you will need to trust this answer.

这篇关于重新启动从PhoneGap的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆