我有一个包含一些服务类的 jar 文件。 jar 放在 Android 的框架中。我想在应用程序中绑定(bind)到该服务。目前我正在使用这个:
Intent intent = new Intent(IMyAidl.class.getName());
boolean returnvalue = mContxt.bindService(intent,connection, Context.BIND_AUTO_CREATE);
System.out.println("Binding to service in jar are not " + returnvalue);
当我使用上面的代码时,我根本无法绑定(bind)。每次false
都是返回值。我不明白为什么它返回 false。
有人可以帮忙吗?
最佳答案
您遇到的最可能的问题是您的构建脚本配置不当。您应该有一个预构建步骤,将类文件复制到将它们转换为 dex 格式的目录。
我见过的另一个常见错误是忘记在应用程序的 list 文件中包含服务声明。如果这不起作用,请提供有关该应用程序的更多详细信息。
关于android - 绑定(bind)到 jar 文件中的服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12016735/