I managed to create a button that launches the contact book and returns a phone number to an editText, upon selection. How do I insert multiple phone numbers into the editText (a.k.a sending sms to a group of people instead of one)
Its better to separate the numbers with comma(",") , so that get list of numbers as
String number = et.getText().toString();
String[] numArr = number.split(",");
try adding multiple phone numbers inside the edit text seperating with SPACE then when you get the text from edit text. do things below...
String temp = edittext.getText().toString();
String[] tempArr = temp.split(" ");
tempArr will contain all the numbers inputed in edit text....
Related
I am scanning the visiting cards and able to get the objects successfully in edit text fields like in image shown below
Below the cropped image the sentences which should be splitted are there I want to split them individually and drag & drop them in another field?
you can split a string to a String array by
String testString="this is a test";
String[] stringArray=testString.split(" ");
in your case you need the new line to do the spliting, so use .split("\n")
then you can copy this to an other location
textbox.setText=stringArray[1];
I'm developing sms APP and want to receive sms from the specific numbers. But number can be changed sometime with country code as +923201234567 or sometime without country code 03201234567 how I can compare number from database? because don't know in which format number is saved in database(with country code or without country code)
public boolean isMember(String phone, long id){
String query = "SELECT * from members where phone = ? AND active = 1 AND gid = ?";
Cursor c = dbActions.rawQuery(query, new String[]{String.valueOf(phone), String.valueOf(id)});
return c.moveToFirst();
}
Suppose if the number is saved in database without country code 03201234567 then my requirement is to get true if I compare it with country code. +923201234567. Country code could be changed.
PhoneNumberUtils.compare(); is not useful because it not compare with database.
If you can't acquire the correct information always; then you need to look into heuristics.
Meaning: you could write your own comparisons; and when you encounter two numbers like:
03201234567
+923201234567
you can figure: their "tail" is equal; the only difference is that the first one starts with 0 (so no country code) and the second one with +92. So it might be reasonable to declare those two numbers to be equal.
So a "solution" would do things like "normalize" your input (remove all non-digit content; except for leading + signs); and to then make such "tail-bound" comparisons.
If that is "too" fuzzy; I guess then you should step back and describe the requirement that you actually try to resolve here. Why are you comparing numbers; and what do you intend to do with the output of that comparison?!
Normalize all of the phone numbers into the same format before you put them into the database. That way you can just do a normal db search.
The other thing I've done for phone numbers is to convert all letters into the appropriate number, then remove all non digits, then just compare the last 7 digits.
I've already been search on how to get the first 2 digit inputed in the EditText but the result was getting the first digit only. In my app I want to make sure that the inputed number is a phone number. I want to be sure that it's started with 09 because it is our countrycode. Is there anyway to do it? Any help will appreciated. Thank you in advance!
Let's say et is your EditText name. You can achieve what you want by using following code.
if (et.getText().toString().startsWith("09")) {
//do what you want
}
Try this
String number = edittext.getText().toString();
String first_two_digits = number.substring(0,2);
first_two_digits are first two numbers of your edittext string
I built a string based numberPicker with all country names, and an editText to function as a search field. I want the numberPicker to refresh\update itself according to what letters the user enters to the search editText. I.E suppose the user types in the letter "I", the picker should show the first country that starts with the letter "I", and update its results according to the rest of the string, like it shows suggestions.
editTextCountryInput = (EditText) findViewById(R.id.editTextCountryInput);
String[] countriesForPicker = new String[236];//array with all countries names
//this fills the country picker with names
private void generateCountryPicker() {
picker.setMinValue(0);
picker.setMaxValue(countriesForPicker.length()-1);
picker.setDisplayedValues(countriesForPicker);
}
Is there any way of doing it?
Posting as an answer so you can close this out*.
You should be able to use a text changed listener like this guy: Android: On EditText Changed Listener
*I'm not too concerned about the points, I just prefer it when people can tell the question has been answered
My team and I are making an android chat application. We want to display the messages sent by the users in a ListView. How can we display the text entered in an EditText in the list view. Or is there any other way to achieve our goal?
It all depends on what type of adapter you're using to back the view. If you're using an ArrayAdapter, just add the text to the array each time you have a new message you want to display (for instance, every time a button was clicked). If you're using a CursorAdapter, you'd then have to add the text to the ContentProvider that the Cursor is viewing. Beyond that, I can't tell you much else. We'd need more details about what you're doing in order to answer any further.
I've done this with some different by your needs. I just get the editText values to my database and printed into EditText. Just see this code -
EditText b = (EditText)findViewById(R.id.editText1);
b.setVisibility(1);
output = (TextView) this.findViewById(R.id.editText1);
output1 = (TextView) this.findViewById(R.id.editText2);
String s1= output1.getText().toString();
this.dh = new DataHelper(this);
this.dh.insert(s1);
List<String> names = this.dh.selectAll();
StringBuilder sb = new StringBuilder();
sb.append("Names in database:\n\n");
for (String name : names)
{
sb.append("\t - \t" + (name) + "\n");
}
this.output.setText(sb.toString());
Just change this with your needs. Try out using this
You can do this using the custom list view. In the custom list view use the custom adapter in which you can take an edit TextView. You can see this how to implement custom list view here. In this list view a TextView is used but you can replace this TextView with EditText view.