title: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
body: <p>Please Help... Whenever I am trying to go to <code>foodDetailActivity</code>..it is throwing page back to the signup-signin activity?? When i debug the fooddetail activity..it is showing below mentioned logcat..</p>
  
  <pre><code>public class FoodList extends AppCompatActivity {
  
      RecyclerView recyclerView;
      RecyclerView.LayoutManager layoutManager;
  
      FirebaseDatabase database;
      DatabaseReference foodList;
      String categoryId="";
  
      FirebaseRecyclerAdapter&lt;Food,FoodViewHolder&gt; adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_food_list);
  
          database=FirebaseDatabase.getInstance();
          foodList=database.getReference("Foods");
  
          recyclerView=findViewById(R.id.recycler_food);
          recyclerView.setHasFixedSize(true);
          layoutManager=new LinearLayoutManager(this);
          recyclerView.setLayoutManager(layoutManager);
  
          if(getIntent() !=null)
              categoryId=getIntent().getStringExtra(CategoryId);
          if(!categoryId.isEmpty() &amp;&amp; categoryId !=null)
          {
              loadListFood(categoryId);
          }
      }
  
      private void loadListFood(String categoryId) {
          adapter=new FirebaseRecyclerAdapter&lt;Food, FoodViewHolder&gt;(Food.class,R.layout.food_item,FoodViewHolder.class,
                  foodList.orderByChild("MenuId").equalTo(categoryId)) {
              @Override
              protected void populateViewHolder(FoodViewHolder viewHolder, Food model, int position) {
  
                  viewHolder.food_name.setText(model.getName());
                  Picasso.with(getBaseContext()).load(model.getImage())
                          .into(viewHolder.food_image);
  
                  final Food local=model;
                  viewHolder.setItemClickListener(new ItemClickListener() {
                      @Override
                      public void onClick(View view, int position, boolean isLongClick) {
                          Intent foodDetail=new Intent(FoodList.this,FoodDetail.class);
                        foodDetail.putExtra(FoodId,adapter.getRef(position).getKey());
                          startActivity(foodDetail);
                      }
                  });
              }
          };
          Log.d("TAG",""+adapter.getItemCount());
          recyclerView.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <p>It is my FoodDetail activity...</p>
  
  <pre><code>public class FoodDetail extends AppCompatActivity {
  
      TextView food_name,food_price,food_description;
      ImageView food_image;
      CollapsingToolbarLayout collapsingToolbarLayout;
      FloatingActionButton btnCart;
      ElegantNumberButton numberButton;
  
      String foodId="";
  
      FirebaseDatabase database;
      DatabaseReference foods;
      Food currentFood;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_food_detail);
  
          database = FirebaseDatabase.getInstance();
          foods = database.getReference("Foods");
  
          numberButton = findViewById(R.id.number_button);
          btnCart = findViewById(R.id.btnCart);
          btnCart.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  new Database(getBaseContext()).addToCart(new Order(
                          foodId,
                          currentFood.getName(),
                          numberButton.getNumber(),
                          currentFood.getPrice(),
                          currentFood.getDiscount()
                  ));
  
                  Toast.makeText(FoodDetail.this, "Added to Cart", Toast.LENGTH_SHORT).show();
              }
          });
  
          food_description = findViewById(R.id.food_description);
          food_name = findViewById(R.id.food_name);
          food_price = findViewById(R.id.food_price);
          food_image = findViewById(R.id.img_food);
  
          collapsingToolbarLayout = findViewById(R.id.collapsing);
  
          collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ExpandedAppbar);
          collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.CollapsedAppbar);
  
          if (getIntent() != null)
              foodId = getIntent().getStringExtra(FoodId);
  
          if(!foodId.isEmpty())
              getDetailFood(foodId);
  
      }
  
      private void getDetailFood(String foodId) {
  
          foods.child(foodId).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  currentFood=dataSnapshot.getValue(Food.class);
  
                  //set image
  
                  Picasso.with(getBaseContext()).load(currentFood.getImage()).into(food_image);
                  collapsingToolbarLayout.setTitle(currentFood.getName());
  
                  food_price.setText(currentFood.getPrice());
                  food_name.setText(currentFood.getName());
  
                  food_description.setText(currentFood.getDescription());
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
      }
  }
  </code></pre>
  
  <p>It is showing error in "if(!foodId.isEmpty())"??</p>
  
  <p>and it is showing below mentioned logcat..</p>
  
  <blockquote>
    <p>02-14 11:49:21.238 6803-6803/com.example.rajatraturi.myrestaur
    E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                     Process: com.example.rajatraturi.myrestaur, PID: 6803
                                                                                     java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.example.rajatraturi.myrestaur/com.example.rajatraturi.myrestaur.FoodDetail}:
    java.lang.NullPointerException: Attempt to invoke virtual method
    'boolean java.lang.String.isEmpty()' on a null object reference
                                                                                         at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
                                                                                         at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
                                                                                         at android.app.ActivityThread.access$900(ActivityThread.java:153)
                                                                                         at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                         at android.os.Looper.loop(Looper.java:148)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:5441)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
                                                                                      Caused by: java.lang.NullPointerException: Attempt to invoke virtual
    method 'boolean java.lang.String.isEmpty()' on a null object reference
                                                                                         at
    com.example.rajatraturi.myrestaur.FoodDetail.onCreate(FoodDetail.java:81)
                                                                                         at android.app.Activity.performCreate(Activity.java:6303)
                                                                                         at
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
                                                                                         at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
                                                                                         at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483) 
                                                                                         at android.app.ActivityThread.access$900(ActivityThread.java:153) 
                                                                                         at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                         at android.os.Looper.loop(Looper.java:148) 
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:5441) 
                                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                                         at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738) 
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)  02-14
    11:49:21.292 6803-6803/com.example.rajatraturi.myrestaur I/Process:
    Sending signal. PID: 6803 SIG: 9</p>
  </blockquote>
  
  <p>help me to solve this..i am not getting what is wrong??</p>