작동하지 않음이 OnPrimaryCLipChangedListener의 구현을위한 내 코드입니다이 OnPrimaryClipChangedListener
package com.example.tryservice;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.content.ClipboardManager.OnPrimaryClipChangedListener;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
@SuppressLint("NewApi")
public class MyService extends Service{
public MyService() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.d("RAJATH", "Service Reached");
ClipboardManager cb = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
cb.addPrimaryClipChangedListener(new PrimaryClipChangedListener());
return 0;
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
}
나는이 서비스를 시작하는 활동을합니다. 이 코드의 목적은 백그라운드에서 클립 보드 변경 내용을 듣는 것입니다. 실수는 어디 있습니까?
해결 방법을 찾으셨습니까? 내 4.3 장치에서 같은 문제를 만났습니다. 충돌은 없지만 로그도 없습니다. 그것은 전혀 등록되지 않은 것처럼. 그러나 동일한 코드가 다른 장치에서 작동하는 것 같습니다. –