错误:尝试调用虚拟方法'java.lang.String java.lang.String.trim()

时间:2019-06-15 02:18:54

标签: java android-studio

我在这部分有问题,我不知道是什么问题。空对象引用上的java.lang.String com.google.firebase.messaging.RemoteMessage $ Notification.getTitle()'。我的getTitle在拒绝服务器应用程序中的调用后返回NULL,以显示在客户端应用程序中。

这是:MyFirebaseMessaging.java 它显示了这一部分: com.moagui.usuario.elys.Service.MyFirebaseMessaging.sendNotificationAPI26(MyFirebaseMessaging.java:38)

TextView txtTime, txtAddress, txtDistance;
Button btnCancel,btnAccept;

MediaPlayer mediaPlayer;

IGoogleAPI mService;
IFCMService mFCMService;

String customerId;

String lat, lng;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custommer_call);

    mService = Common.getGoogleAPI();
    mFCMService = Common.getFCMService();

    btnAccept = (Button)findViewById(R.id.btnAccept);
    btnCancel = (Button)findViewById(R.id.btnDecline);

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!TextUtils.isEmpty(customerId))
                cancelBooking(customerId);
        }
    });

    btnAccept.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(CustommerCall.this,DriverTracking.class);
            //Send customer loaction to new Activity
            intent.putExtra("lat",lat);
            intent.putExtra("lng",lng);
            intent.putExtra("customerId",customerId);

            startActivity(intent);
            finish();
        }
    });



    //Init View
    txtAddress = (TextView)findViewById(R.id.txtAddress);
    txtDistance = (TextView)findViewById(R.id.txtDistance);
    txtTime = (TextView)findViewById(R.id.txtTime);

    mediaPlayer = MediaPlayer.create(this,R.raw.ringtone);
    mediaPlayer.setLooping(true);
    mediaPlayer.start();

    if (getIntent() != null)
    {
        lat = getIntent().getStringExtra("lat");
        lng = getIntent().getStringExtra("lng");
        customerId = getIntent().getStringExtra("customer");

        //Just copy getDirection from Welcome Activity
        getDirection(lat,lng);
    }
}

private void cancelBooking(String customerId) {
    Token token = new Token(customerId);

    //Notification notification = new Notification("¡Cancelado!","El conductor ha cancelado tu solicitud");
    //Sender sender = new Sender(token.getToken(),notification);

    Map<String,String> content = new HashMap<>();
    content.put("title","¡Cancelado!");
    content.put("message","El conductor ha cancelado tu solicitud");
    DataMessage dataMessage = new DataMessage(token.getToken(),content);

    mFCMService.sendMessage(dataMessage)
            .enqueue(new Callback<FCMResponse>() {
                @Override
                public void onResponse(Call<FCMResponse> call, Response<FCMResponse> response) {
                    if (response.body().success == 1)
                    {
                        Toast.makeText(CustommerCall.this, "Cancelado", Toast.LENGTH_SHORT).show();
                        finish();
                    }
                }

                @Override
                public void onFailure(Call<FCMResponse> call, Throwable t) {

                }
            });
}

0 个答案:

没有答案