0
다음은 제 코드입니다.서비스를 중지 할 수 없습니다.?
package com.callplus;
import java.io.IOException;
import android.app.Activity;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
public class AudioRecordTest extends Service {
private static String TAG = "AudioRecordTest";
private static String FileName = null;
private MediaRecorder Recorder = null;
public static String callerName, date, path,number;
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "I am in Oncreate");
DBAdapter db = new DBAdapter(this);
db.open(SQLiteDatabase.NO_LOCALIZED_COLLATORS);
db.getPath();
path = db.audioPath;
db.close();
final TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(new PhoneStateListener() {
public void onCallStateChanged(final int state,
final String incomingNumber) {
try {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
if (Recorder != null) {
Recorder.release();
Recorder.stop();
}
Log.d("TestActivity", "Call is idle.");
actionStop(getApplicationContext());
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d("TestActivity", "Call connected");
startRecording();
break;
case TelephonyManager.CALL_STATE_RINGING:
break;
default:
break;
}
} finally {
}
}
}, PhoneStateListener.LISTEN_CALL_STATE);
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onDestroy()
{
super.onDestroy();
stopSelf();
}
public static void actionStop(Context ctx)
{
Intent i = new Intent(ctx, AudioRecordTest.class);
Log.d(TAG, "I am in ActionStop");
// i.setAction(ACTION_STOP);
ctx.startService(i);
}
}
유휴 상태 일 때 서비스를 중지하고 싶습니다.
의 workng하지 still.what를 사용? ACTION_STOP에서 해결할 수 없습니다. – Hitesh