如何强制Android应用的崩溃,从科尔多瓦插件类? [英] How to force a crash of Android app, from a Cordova plug-in class?

查看:130
本文介绍了如何强制Android应用的崩溃,从科尔多瓦插件类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要强制的Andr​​oid应用程序的崩溃,从科尔多瓦内部插件类。

I need to force the crash of an Android App, from inside a Cordova plug-in class.

问题是,插件类在独立的线程中运行,所以即使我强制的RuntimeException(),它崩溃只是独立的线程。

The problem is that the plug-in class runs in a separated Thread, so even if I force a RuntimeException(), it crashes just the separated thread.

推荐答案

如果您要崩溃了从科尔多瓦插件/或Android应用pressing菜单按钮,您可以在提到科尔多瓦项目编辑几类应用<一href=\"http://stackoverflow.com/questions/28340920/how-to-make-my-phonegap-android-app-crash/29875804#29875804\">how让我PhoneGap的Andr​​oid应用程序崩溃?。

If you want to crash the app from cordova plugin/or pressing menu button in android app you have to edit few classes in cordova project as mentioned in how to make my phonegap android app crash?.

通过从Javascript调用一些本地函数崩溃:

写出的PhoneGap的Andr​​oid原生插件。请参阅的http://docs.phonegap.com/en/3.0.0/guide_platforms_android_plugin.md.html#Android%20Plugins为创建插件。抛出异常内执行方法。这将父层(这就是为什么你可以看到有关的崩溃日志在控制台),所以请不要如下更改,使应用程序崩溃(无论是类属于org.apache.cordova包)在处理

Write an Android native plugin for Phonegap. Refer http://docs.phonegap.com/en/3.0.0/guide_platforms_android_plugin.md.html#Android%20Plugins for plugin creation. Throw exception inside execute method. This will be handled in the parent layer(Thats why you can see logs about crash in the console), So please do following changes to make the app crash.(Both the classes belong to org.apache.cordova package)


  • 删除赶上(例外五){} 块中的 execHelper 插件管理类里面的方法。

  • 删除赶上(Throwable的E){} EXEC ExposedJsApi 类的方法。

  • Remove catch (Exception e){} block in execHelper method of pluginManager classs.
  • Remove catch (Throwable e) {} block in exec method of ExposedJsApi class.

随着这一变化,我能够从JavaScript调用应用程序崩溃。

With this change I am able to crash the application from javascript call.

这篇关于如何强制Android应用的崩溃,从科尔多瓦插件类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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