无法根据我在 AlertDialog 中给出的位置购买名称

Not able to shop name based on location I given in AlertDialog

   AllArea.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    //get the place values as popup window
    String[] items = {"All-Area","Cheruvathur", "Kanhangad","Nileswaram","Panathur","Periya","Thrikkaripur","Vellarikkundu"};
    AlertDialog.Builder  builder=new AlertDialog.Builder(context);
    builder.setTitle("Choose Area: ");
    builder.setItems(items, new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int item)
    {
    //AllArea.setText(items[item]);
    if(items[item].equals("All-Area"))
    {
    AllArea.setText(items[item].toString());
    //System.out.println(AllArea);
    String getAllArea=AllArea.getText().toString();
    Intent i=new Intent(SecondPage.this,Order.class);
    i.putExtra("getAllArea", getAllArea);
    startActivity(i);
    Toast.makeText(getApplicationContext(),"All-Area",Toast.LENGTH_SHORT).show();
    }
    else if(items[item].equals("Cheruvathur"))
    {
    AllArea.setText(items[item].toString());
    Intent j=new Intent(SecondPage.this,Order.class);
    String getCheruvathur=AllArea.getText().toString();
    j.putExtra("getCheruvathur", getCheruvathur);
    startActivity(j);
    //System.out.println(AllArea);
    Toast.makeText(getApplicationContext(),"Cheruvathur",Toast.LENGTH_SHORT).show();
    }
    }
    }
    });

无法根据给定位置查看商店名称并在另一个位置显示其名称activity,

请帮我看看是什么问题

店铺位置选择值代码

Intent All=getIntent();
String Allnew=All.getStringExtra("getAllArea");
            if (Allnew.equals("All-Area")) {

                list = new ArrayList<>();
                list.add("3G mobile : Chevtr");
                list.add("Spice World : kngd");
                list.add("Dotcom : nslrm");
                list.add("Pv Stores: Pya");
                list.add("Sky World : Pntur");
                list.add("Mobile Galaxy : trkppr");
                list.add("Dream Mobile : vlkdu");
                list.add("Tele World : Chevtr");
                list.add("Info Tech Solutions : Pya");
                list.add("MYG Mobile : trkppr");
              // adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
             // listView.setAdapter(adapter);
            }




 Intent Cheru=getIntent();
        String Cherunew=Cheru.getStringExtra("getCheruvathur");
       if (Cherunew.equals("Cheruvathur")) {

          list1 = new ArrayList<>();
          list1.add("3G mobile : Chevtr");
          list1.add("Tele World : Chevtr");

         //  adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
          // listView.setAdapter(adapter);
       }

请帮我解决问题 显示这是错误的日志猫

NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a null object reference

这里的问题是,在您的 Order class 中,您的代码试图获取 getAllAreaCheruvathurStringExtra,而这将导致崩溃,因为它们中只有一个存在,因为您一次调用一个 Intent。因此,一种解决方案是您可以简单地检查 IntentStringExtra 是否不是 null 并且只需对您的代码进行少量修改就可以正常工作,试试这个。

Intent intent=getIntent();
if(intent.getStringExtra("getAllArea")!= null)
                list = new ArrayList<>();
                list.add("3G mobile : Chevtr");
                list.add("Spice World : kngd");
                list.add("Dotcom : nslrm");
                list.add("Pv Stores: Pya");
                list.add("Sky World : Pntur");
                list.add("Mobile Galaxy : trkppr");
                list.add("Dream Mobile : vlkdu");
                list.add("Tele World : Chevtr");
                list.add("Info Tech Solutions : Pya");
                list.add("MYG Mobile : trkppr");
              // adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
             // listView.setAdapter(adapter);
            } 

else if(intent.getStringExtra("Cheruvathur")!= null)
          list1 = new ArrayList<>();
          list1.add("3G mobile : Chevtr");
          list1.add("Tele World : Chevtr"); 

         //  adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
          // listView.setAdapter(adapter);
       }