Search code examples
androidandroid-intentintentfilter

Send only text not number/icon using passing data with intent


How I,m send only text not number/icon using passing data with intent. Thank Before Guys.

Example i send string : Bali (1120). i will receive only : Bali

Send data intent :

 Intent hotelLocation = new Intent(view.getContext(), HotelActivity.class);
 hotelLocation.putExtra("Location", tvHotelFind.getText().toString());
 hotelLocation.setType("text/plain");
 view.getContext().startActivity(hotelLocation);

Receive data Intent :

String titleresult = getIntent().getStringExtra("Location");
mHotelTujuan.setText(titleresult);

Solution

  • Remove all number before send

    String yourString = tvHotelFind.getText().toString(); 
    yourString = yourString.replaceAll("[^A-Za-z]", ""); 
    hotelLocation.putExtra("Location", yourString);
    

    And then pass intent with yourString.