0

サービスと作成した別のクラスとの間でエクストラをバンドルしようとしていますが、強制終了エラーが発生して「java.lang.NullPointerException at com.test.generic.clientprovisioninghandler.DataCountService.onStartCommand(DataCountService) .java:46)"

Bundle extras = getIntent().getExtras(); の行はどれですか。

これを修正する方法についての提案は大歓迎です!

ソース:

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")) {
4

2 に答える 2