注册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
<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
另外android里一般用Log.d()来输出调试信息。
是呀,Android一般都是用Log来打印输出日志的~~
用Logcat