서비스를 시작하고 종료하려고합니다. 내 서비스는 로그입니다.서비스 만드는 법 Android 프로그래밍
package com.example.textsmslock;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
public class Logs extends Service
{
@Override
public IBinder onBind(Intent arg0){
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
System.out.println("LOGS STARTED");
Log.d("TAG", "FirstService started");
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
}
를 호출하는 활동은 ConfirmPin입니다. 함수에서 로그를 호출 중입니다.
// imports...
// public class...
public void ConfirmingPin()
{
if(pinCorrect)
{
startService(new Intent("com.example.textsmslock.Logs"));
}
}
여기 내 AndridManifest입니다
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.textsmslock"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".ConfirmPin"
android:label="@string/title_activity_confirm_pin" >
<intent-filter>
<action android:name="com.example.textsmslock.ConfirmPin" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service android:name=".Logs"/>
</application>
로그 캣는 말한다 :
서비스 의도를 시작할 수 없습니다 {행위 = com.example.textsmslock.Logs} :하지 발견 된
서비스 의도를 시작할 수없는 이유를 아는 사람이 있습니까?
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
을 그리고 서비스 시작 :
@rekire 대부분의 편집에 동의하지만 LogCats는 코드 블록으로 묶지 않아야한다. 에스. 따옴표 블록은 여러 행의 LogCats에서 줄 바꿈을 무시하므로 스택 추적을 거의 읽을 수 없습니다. – Sam
@Sam 일반적으로 나는 역시 그렇게하지만 한 라이너는 아닙니다. – rekire
@rekire 두 가지 표준을 사용하는 이유는 무엇입니까? 옆에서 나는 기술적 인 LogCat을 좋아하게되었다. :) – Sam