请帮助我找出此错误
试图在空对象引用上调用虚拟方法
double android.location.Location.getLatitude()
private void updateList() {
FirebaseRecyclerOptions<User> userOptions = new
FirebaseRecyclerOptions.Builder<User>()
.setQuery(counterRef,User.class)
.build();
mLastLocation = null;
adapter = new FirebaseRecyclerAdapter<User, ListOnlineViewHolder>(userOptions) {
@Override
protected void onBindViewHolder(@NonNull ListOnlineViewHolder viewHolder, int position, final User model) {
if (model.getEmail().equals(FirebaseAuth.getInstance().getCurrentUser().getEmail()))
viewHolder.txtEmail.setText(model.getEmail() + " (me)");
else
viewHolder.txtEmail.setText(model.getEmail());
viewHolder.itemClickListener = new ItemClickListener() {
@Override
public void onClick(View view, int position) {
if (!model.getEmail().equals(FirebaseAuth.getInstance().getCurrentUser().getEmail())) {
Intent map = new Intent(ListOnline.this, MapsActivity.class);
map.putExtra("email", model.getEmail());
map.putExtra("lat", mLastLocation.getLatitude());
map.putExtra("lng", mLastLocation.getLongitude());
startActivity(map);
}
}
};
}
-----------------------------------------------------------
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
public class ListOnlineViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public TextView txtEmail;
ItemClickListener itemClickListener;
public ListOnlineViewHolder(View itemView) {
super(itemView);
txtEmail = (TextView)itemView.findViewById(R.id.txt_email);
itemView.setOnClickListener(this);
}
public void setItemClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
@Override
public void onClick(View view) {
itemClickListener.onClick(view,getAdapterPosition());
}
}
java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference
at mariposa.yashida.com.ListOnline$1$1.onClick(ListOnline.java:195)
at mariposa.yashida.com.ListOnlineViewHolder.onClick(ListOnlineViewHolder.java:27)
at android.view.View.performClick(View.java:5265)
at android.view.View$PerformClick.run(View.java:21534)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5765)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)