Hi
I wan to create a contact, so here is my code:
Intent addPersonIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
addPersonIntent.putExtra(Insert.NAME, "asd");
addPersonIntent.setType(Contacts.People.NAME);
addPersonIntent.putExtra(Insert.PHONE_TYPE, Contacts.Phones.TYPE_WORK);
addPersonIntent.putExtra(Insert.PHONE, Uri.decode("123"));
addPersonIntent.putExtra(Insert.PHONE_TYPE, Contacts.Phones.TYPE_MOBILE);
addPersonIntent.putExtra(Insert.PHONE, Uri.decode("123"));
addPersonIntent.setType(Contacts.Phones.CONTENT_ITEM_TYPE);
...
startActivity(addPersonIntent);
Why the only thing that is created is the mobile number, I never got the "work" number?
You're thinking of "putExtra" as adding to the end of an array - Your problem will be clearer if you think of it as setting name/value pairs in a hashtable. Basically, you're setting PHONE_TYPE to "work", PHONE to 123, PHONE_TYPE to "mobile" (overwriting when it was set to work), and PHONE to "123" again.
What you want to do is set either the "mobile" or "work" phone data using SECONDARY_PHONE and SECONDARY_PHONE_TYPE - Details here.
Also, keep in mind that all this follows the old version of the Contacts API, which is deprecated as of Android 2.0+. There's a handy resource on migrating your code to use the new contacts API here.
here is the next problem, when I add:
addPersonIntent.putExtra(Insert.NOTES, "asdkjhaskh");
the note data never appears in the activity, why?
The whole idea is to start the EditContactActivity.java with loaded data and for now I loaded phones, names and companies. For some reason I cant load notes, and another problem is how to set in the intent information for the IM? For example I tryed with:
addPersonIntent.putExtra(Insert.IM_HANDLE, "mySkype");
addPersonIntent.putExtra(Insert.IM_PROTOCOL, Uri.decode("skype"));
but it is not working.
Related
I am trying to make a performance testing process by using the Jmeter for the mobile chat application. The scenario i am trying is,need to analyze the output during the N number of new user registration process.I am feeding the N user data through "CSV Data Set Config".In that mentioned the variable names as "phone,ime".
For each new user registration process,the application will generate the one time password when calling the API1.The question is,I need to get that generated one time password from the API1 response message for each phone user and need to assign the value to the variable ${code} when calling the API2.
The below are the API & parameters details:
API1:/api/users/registration-sms.html?
1) Name:phone, Value: ${phone}
2) Name:ime, Value: ${ime}
Example :
Request - POST data: phone=917010370002 & ime=e78b56418b55b32c
Response:{"response":{"httpCode":200,"Message":"True","Code":"5858"}}
API2: /api/users/registration-sms-verfy.html?
1) Name:phone, Value:${phone}
2) Name:code, Value:${code}
Note : For this variable ${code},We need to get the data from the API1("Code":"5858") response message for the respective phone(917010370002).
Please provide me the feasible solution to sort out of my requirement.
Thanks in advance.
You can use Regular extractor post processor like,
Assuming your response is like
{"response":{"httpCode":200,"Message":"True","Code":"5858"}}
your regular expression will be like to extract code value but for specifiic phone no you need to modify it a little bit,
"Code"\:"(\d+)"
for occurance detail you can provide which match no. you want.
Refer Regular Expression Exctrator Post Processor
I have successfully added a word to Android's predefined user dictionary, but i want to create a custom dictionary which can only be accessed by my application.
For example: When i type "lol", the suggestions show me "laugh out loud" but when I want another meaning of "lol" then I can manually add another meaning of "lol" (eg, "xxxxxx" - so the next time the user writes "lol" in an EditText, the suggestions will show him "xxxxxx").
No other application should have access my dictionary data.
I have worked with spell checker class but it gives me only correct word and I can't my own word meanings.
Please give me some suggestions or links.
There is an Androids inbuilt class UserDictionary so that you can add your spells programmatically into that, Here is a link you can go through with , and which may relates to your problem .(In this solution nidhi has manged programmatically to retrieve data back)
Add word to user dictionary and retrieve them back from dictionary
In addition you can go through following links to :
http://developer.android.com/reference/android/provider/UserDictionary.html
http://developer.android.com/reference/android/provider/UserDictionary.Words.html
Moreover if you want a custom personal dictionary then manually you have to store words and retrieve them back .
Hope that helps !!!
I am new to Parse and i am working on a Project that uses Android PARSE Sdk so i was wondering on how can i make a where query with or condition using the android sdk.
I want to make a query like this [Psuedo code]
Select * from employ where employId is ("1","2","3")
I found this on parse documentation, i don't know if it helps or not.
Edit:
This is what i found on PARSE but its not working
String[] id= {"1","2","3"};
query.whereContainedIn("employId ", Arrays.asList(id));
It returns me an empty list but if i query them one by one i get result... Can anyone tell me whats wrong ?
You can use whereContainedIn to select specific rows. See this post you can get more ideas. https://www.parse.com/questions/different-arrays-and-wherecontainedin-for-android.
List<String> employId = new ArrayList<String>();
employId.add("1"); employId.add("2"); employId.add("2");
query.whereContainedIn("employId", employId);
If you are still not clear. check this https://www.parse.com/docs/android_guide#queries
I have found the solution and i must say its pretty lame of PARSE to not mention this anywhere in there documentation.
The problem was that the values that i was using inwhereContainedIn method were of type String but in reality they were pointers to another table's row.
I was trying to get the values using only there ids[as it is displayed on parse] but instead i had to pass the whole object in order to retrieve them. That was the reason on why it was returning empty list.
The thing is Even though it displays IDs [pointer to object in a table] we cant search using only ID's instead we have to use complete Parse objects if we want to search a table based on Specific Object.
Trying to call number with name.It is possible to make name with number calling.
I successfully calling following code:
Intent callIntentp2 = new Intent(Intent.ACTION_CALL);
callIntentp2.setData(Uri.parse("tel: 55555555");
startActivity(callIntentp2);
It's Output looks like
55555555 Dialing
But I want to call with name just like you saved on contact list on your sim.but i have data in manually not from sim.
John 55555555 Dialing
Is that possible.
ACTION_CALL is a native Android intent. When you call it, Android performs background processes that bring up the default call view. There are ways you could chop together some broadcast receiver to overlay an activity on top of the native call screen, but you are asking for trouble on that end. Without a rooted device, this is a difficult process. This question is actually very similar to:
Replace native outgoing call Screen by custom screen android
I haven't read through the link or anything, but I am pretty sure they are going to say the same thing. Without doing some weird, iffy work-around you aren't likely to achieve this.
You could (theoretically) take the time prior to calling to add the number with the attached name to your contacts list. When the call is made, it will show the name and the number (since the name is listed as a contact and that is Android's default action). Once the call is done you could delete the contact so that it doesn't get stuck in a persons contact list that doesn't want it.
A bit of code for example:
ContentValues contactValues = new ContentValues();
contactValues.put(Data.RAW_CONTACT_ID, 001);
contactValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
contactValues.put(Phone.NUMBER, "555-555-5555");
contactValues.put(Phone.TYPE, Phone.TYPE_CUSTOM);
contactValues.put(Phone.LABEL, "John");
Uri dataUri = getContentResolver().insert(
android.provider.ContactsContract.Data.CONTENT_URI, contactValues);
Don't forget to add write contact permission to your applications manifest. Again, this is just an option (the only one I can really think of off the top of my head)
When changing the custom locale the label of the phone types change to the appropriate language. Does anybody know how to get the localized label of the phone types?
I pick a contact in my app to get its phone number and if there is more then one number I use an AlertDialog to let the user select the currect one. In this pick list, I want to show the label of the type, so it's easier for the user to select. Since they labels are somewhere in the Android system, it must be possible to get the localized label. Unfortunately, the Phone.LABEL is null when reading the phone number.
I know this is a bit old, but this:
Phone.getTypeLabel(this.getResources(), cursor.getInt(typeIdx), "");
worked for me
Yes, you can get localized phone type string with the code:
int phoneNumberType = (int)pCur.getInt(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
ContactsContract.CommonDataKinds.Phone.getTypeLabel(context.getResources(), phoneNumberType , "")
but for custom phone types you should cosider phone label, not only phone type:
String phoneLabel = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL));
Inferno's answer is a valid answer, and I was happy to find this answer because it was similar to what I was looking for. However, if you're dealing with phones installed with API Level 5 (Android 2.0) or newer, there is one small problem with this: android.R.array.phoneTypes only returns the list of phone types that were present prior to when ContactsContract class replaced the Contacts interface as of API Level 5. I verified the labels listed when creating a new contact on emulators running these Android versions (API Levels): 1.6 (4), 2.1-update 1 (7), and 2.2 (8).
When printed out, android.R.array.phoneTypes contains these valid phone types:
Home, Mobile, Work, Work Fax, Home Fax, Pager, Other, Custom
These are the valid phone types, present for phones with Android 2.0+ installed, that are missing from that same Array:
Callback, Car, Company Main, ISDN, Main, Other Fax, Radio, Telex, TTY TDD, Work Mobile, Work Pager, Assistant, MMS
Unfortunately, I have not been able to find something like android.R.array.phoneTypes that'll list all of these valid phone types for phones Android 2.0+. Has anyone come across such yet?
References
android.R.array.phoneTypes defined: http://developer.android.com/reference/android/R.array.html#phoneTypes
Note: I'm posting my other two reference links in separate answers, as I can't seem to post more than one hyperlink per post at this time.
i am using this piece of code
public void getPhoneType(){
int res;
for(int i=0;i<=20;i++){
res = ContactsContract.CommonDataKinds.Phone.getTypeLabelResource(i);
Log.d(TAG,"i: "+ i +" type: " + context.getString(res));
}
}
didn't found any place to get the actual count of valid types but http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Phone.html#getTypeLabelResource%28int%29 says it will always give a valid res so, you can iterate until it start giving repeated values... to me after 20 gives me the custom res.