서비스와 내가 만든 다른 클래스 사이에 추가 기능을 번들로 제공하려고하지만 "java.lang"이라는 강제 종료 오류로 인해 문제가 있습니다. com.estroy.contentinghandler.DataCountService.onStartCommand (DataCountService.java:46)에서 NullPointerException "NullPointerException 서비스와 다른 클래스 사이의 추가 기능을 번들로 사용하려고 시도 할 때
번들로 제공되는 extras = getIntent(). getExtras();
이 문제를 해결하는 방법에 대한 제안은 크게 감사드립니다!
자료 제공 :
private Intent getIntent() {
// TODO Auto-generated method stub
return null;
}
항상 null을 반환 :
당신에public class DataCountService extends Service {
String text = "USR;1";
String ERROR = Constants.PREFS_NAME;
private Timer timer = new Timer();
private long period;
private long delay_interval;
private Intent getIntent() {
// TODO Auto-generated method stub
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(Constants.TAG, "Logging Service Started");
if (intent == null) {
// Exit gracefully is service not started by intent
Log.d(Constants.TAG, "Error: Null Intent");
} else {
Bundle extras = getIntent().getExtras();
if (extras != null) {
text = extras.getString(Constants.DM_SMS_CONTENT);
// check for Enable or Disable Value - if set to enable
// check for Enable or Disable Value - if set to enable
if (extras.getString(Constants.DM_SMS_CONTENT).contains(
"//USR;1")) {