ITeye博客

调用service静态方法抛RuntimeException问题

hemowolf · 2013-02-06 10:50 · android · 移动开发 · Service · static · runtimeexception · Markdown

假设有一个service类是 AbcSvr在其内有一个static方法供外调用启动自己。

    public static void startAbcSvr(Context ctx ) {
	      ctx.startService(new Intent(ctx, AbcSvr.class));
    }

   在某种情况下回抛出Exception

   Exception Ljava/lang/RuntimeException; thrown while initializing Lcom/XXXX/AbcSvr;
   

    应是Dalvik的一个bug。解决的办法是将startAbcSvr方法移动到其他类去即可。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。