您好:我想启动一项位于连接的图书馆项目中的服务。所有相关课程都在图书馆。
该服务是从位于库中的活动调用的:
Intent serviceIntent = new Intent();
serviceIntent.setAction("org.example.library.MY_ACTION");
startService(serviceIntent);
在库和应用程序的清单文件中,注意到:
<service android:name="org.example.library.SomeLibraryClass">
<intent-filter>
<action android:name="org.example.library.MY_ACTION" />
</intent-filter>
</service>
无法启动服务 Intent { act=org.example.android.SomeLibraryClass (has extras) }: 未找到
看起来 Android 正在应用程序中寻找类,而不是在库中寻找类。以前有人有过这种行为吗?
调用库中定义的Intent时,需要指定应用程序的包:
Intent serviceIntent = new Intent();
serviceIntent.setAction("org.example.library.MY_ACTION");
serviceIntent.setPackage("org.example.application");
startService(serviceIntent);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)