奇怪的问题。。。为什么不能启动service
注册service:<service android:enabled="true" android:name=".service.FirstService"></service>
启动service:
public void onClick(View v)
{
// TODO Auto-generated method stub
System.out.println("onClick");
Intent intent = new Intent();
intent.setClass(testService.this, FirstService.class);
startService(intent);
System.out.println("after startService");
}
public void onCreate()
{
// TODO Auto-generated method stub
System.out.println("onCreate");
super.onCreate();
}
public void onStart(Intent intent, int startId)
{
// TODO Auto-generated method stub
System.out.println("onStart");
super.onStart(intent, startId);
}
编译,运行都没有错,但就是不能打印出“onCreate”和“onStart”。不能启动service --------------------编程问答-------------------- 你是在DDMS的Logcat里查看的么?
另外android里一般用Log.d()来输出调试信息。 --------------------编程问答--------------------
是呀,Android一般都是用Log来打印输出日志的~~ --------------------编程问答-------------------- System.out.println( "onCreate "); 打到哪里去了你知道不 你也看不到呀
用Logcat --------------------编程问答-------------------- 加QQ:465144122
帮你看看代码吧! --------------------编程问答-------------------- 用Log.d("", "")输出log,在Logcat下面查看log输出。 --------------------编程问答-------------------- 你在 activity里怎么搞的? --------------------编程问答-------------------- 已经解决了,是因为service所在的类和这个activity不在同一个package. --------------------编程问答--------------------
补充:移动开发 , Android