我使用最新的 Android 工具在 Eclipse 3.8 中创建了这个最简单的服务项目(基于 this )并将其发布在这里: https://github.com/8enmann/hello-service/
启动时出现以下错误:
02-03 00:18:45.984: E/AndroidRuntime(20145): java.lang.RuntimeException:
Unable to start activity ComponentInfo{net.softmann/net.softmann.HelloActivity}:
android.content.ActivityNotFoundException:
Unable to find explicit activity class {net.softmann/net.softmann.HelloService};
have you declared this activity in your AndroidManifest.xml?
但它在我的 list 中!我究竟做错了什么?我也尝试过使用“net.softmann.HelloService”而不是“.HelloService”,但仍然没有成功。
最佳答案
异常表明您正在尝试启动 Activity net.softmann/net.softmann.HelloService
但未找到该 Activity 。
查看您的 list 文件,您有一个具有此类名称的服务。
查看您的 Activity 代码,您已经
startActivity(new Intent(getApplicationContext(), HelloService.class));
使用 startService()
启动服务,而不是 startActivity()
。
关于java - 尽管 Eclipse 中的一切都正确,但 Android ActivityNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21522589/