1gravity / android-contactpicker Goto Github PK
View Code? Open in Web Editor NEWA beautifully designed component to pick one or several contacts (including groups) from the Android contacts list
License: Apache License 2.0
A beautifully designed component to pick one or several contacts (including groups) from the Android contacts list
License: Apache License 2.0
Hello
When using the library on my device, there are two scrollbars in the Activity:
For me, it seems strange.
Why do we need the native RecyclerView's scrollbar? It is explicitly set with android:scrollbars="vertical"
on the RecyclerView in cp_contact_list.xml
.
Is it an accident or is it intended for some reason? I can either remove that or add an extra parameter to show/hide it. What do you think?
This feature request is about providing a similar option as EXTRA_ONLY_CONTACTS_WITH_PHONE (Boolean), but for having an email account (e.g. only show contacts that have at least a mail account.
I just found this yesterday and decided to use this in my app due to its good features. I did everything as mentioned in the steps but when i am starting the activity I am getting a Toast message saying
Attribute undefined; "cp_textColorPrimary". Did you apply the correct theme
i have checked the documentation of library and heres what i did 1) Added dependency to gradle 2) Added activity file to manifest 3) Enabled contacts permission 4) below is the code
`Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ContactPickerActivity.class)
.putExtra(ContactPickerActivity.EXTRA_THEME, R.style.ContactPicker_Theme_Dark)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_BADGE_TYPE,
ContactPictureType.ROUND.name())
.putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION,
ContactDescription.ADDRESS.name())
.putExtra(ContactPickerActivity.EXTRA_SHOW_CHECK_ALL, true)
.putExtra(ContactPickerActivity.EXTRA_SELECT_CONTACTS_LIMIT, 0)
.putExtra(ContactPickerActivity.EXTRA_ONLY_CONTACTS_WITH_PHONE, false)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION_TYPE,
ContactsContract.CommonDataKinds.Email.TYPE_WORK)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_SORT_ORDER,
ContactSortOrder.AUTOMATIC.name());
startActivityForResult(intent, REQUEST_CONTACT);
}
});`
can anyone please help me out with this
Hi, I've followed your steps but I got this error.
Attribute undefined:
"cp_textColorPrimary". Did you apply the correct theme?
What did I missed?
Thank You
Hi , i tried to implement your library into my project but I get this log : E/ContactPickerActivity: Contact permission hasn't been granted to this app, terminating.: uid 10061 does not have android.permission.READ_CONTACTS.
even thought i added the line <uses-permission android:name="android.permission.CONTACTS" />
to my Android manifest file.
Thanx in advance for your help.
SDK used : 23
Build : skd_google_phoneX86_64-userdebug 6.0 MASTER 3038907 test-keys
Device : Samsung s5 simulator
I am unable to show all three Menu item on action bar. it shows only 2 Search and Check all either Search and OK.
Hello! I'm on Android 7.1.1 and I'm getting this error with your lib:
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.aflak.myapp/com.onegravity.contactpicker.core.ContactPickerActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.design.widget.TabLayout
Do you know why is this happening ?
Thanks!
In <style name="Theme_Light_Base" parent="@style/ContactPicker_Theme_Light">
if I change the background color item to <item name="backgroundColor">#e5eaee</item>
this doesn't get picked up by the contactpicker (cp_contact_list.xml
I think) - is it possible for the background to be changed?
--------- beginning of crash
2018-11-14 15:34:22.585 15602-15602/com.cooldoctors.peermd E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cooldoctors.peermd, PID: 15602
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {com.cooldoctors.peermd/com.cooldoctors.peermd.activities.InviteActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.hasExtra(java.lang.String)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4324)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4367)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1649)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.hasExtra(java.lang.String)' on a null object reference
at com.cooldoctors.peermd.activities.InviteActivity.onActivityResult(InviteActivity.java:68)
at android.app.Activity.dispatchActivityResult(Activity.java:7235)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4320)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4367)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1649)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) ``
When i click on the button to start ContactPickerActivity, it is showing this error.
Attribute undefined. cp_TextColorPrimary Did you apply to correct theme.
I want to set the AppTheme which is my default App theme.
.putExtra(ContactPickerActivity.EXTRA_THEME, R.style.AppTheme)
I have read that
/**
* Use this parameter to set the Theme for this activity.
* It's the theme's resource id (like R.style.YourFancyTheme)..
* Please note that the theme needs to define the attributes defined in attrs.xml or the
* Activity will crash. You can either extend the library's theme(s) or define the attributes in
* your custom theme.
*/
What are other attributes that I need to set.
Hello,
is there a way to send the contacts that I want to be checked when the user open contactpicker view?
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amastigote.templatemsg/com.onegravity.contactpicker.core.ContactPickerActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.design.widget.TabLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) at android.app.ActivityThread.access$1100(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7232) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.design.widget.TabLayout at android.view.LayoutInflater.inflate(LayoutInflater.java:551) at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) at android.view.LayoutInflater.inflate(<Xposed>) at android.view.LayoutInflater.inflate(LayoutInflater.java:429) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.onegravity.contactpicker.core.ContactPickerActivity.onCreate(ContactPickerActivity.java:298) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) at android.app.ActivityThread.access$1100(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7232) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.support.design.widget.TabLayout at android.view.LayoutInflater.createView(LayoutInflater.java:657) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) at android.view.LayoutInflater.inflate(LayoutInflater.java:527) at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) at android.view.LayoutInflater.inflate(<Xposed>) at android.view.LayoutInflater.inflate(LayoutInflater.java:429) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.onegravity.contactpicker.core.ContactPickerActivity.onCreate(ContactPickerActivity.java:298) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) at android.app.ActivityThread.access$1100(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7232) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:631) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) at android.view.LayoutInflater.inflate(LayoutInflater.java:527) at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) at android.view.LayoutInflater.inflate(<Xposed>) at android.view.LayoutInflater.inflate(LayoutInflater.java:429) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.onegravity.contactpicker.core.ContactPickerActivity.onCreate(ContactPickerActivity.java:298) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) at android.app.ActivityThread.access$1100(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7232) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 9: TypedValue{t=0x2/d=0x7f01012a a=-1} at android.content.res.TypedArray.getColorStateList(TypedArray.java:484) at android.content.res.XResources$XTypedArray.getColorStateList(XResources.java:1319) at android.support.design.widget.TabLayout.<init>(TabLayout.java:341) at android.support.design.widget.TabLayout.<init>(TabLayout.java:290) at java.lang.reflect.Constructor.newInstance(Native Method) at android.view.LayoutInflater.createView(LayoutInflater.java:631) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) at android.view.LayoutInflater.inflate(LayoutInflater.java:527) at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) at android.view.LayoutInflater.inflate(<Xposed>) at android.view.LayoutInflater.inflate(LayoutInflater.java:429) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.onegravity.contactpicker.core.ContactPickerActivity.onCreate(ContactPickerActivity.java:298) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) at android.app.ActivityThread.access$1100(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7232) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
Project info:
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
applicationId "com.amastigote.templatemsg"
minSdkVersion 19
targetSdkVersion 25
versionCode 3
versionName "1.2"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
When some contacts don't have WORK email address. The following will return the same email address.
Log.d("Contact", "Home="+contact.getEmail(ContactsContract.CommonDataKinds.Email.TYPE_HOME));
Log.d("Contact", "Work="+contact.getEmail(ContactsContract.CommonDataKinds.Email.TYPE_WORK));
Is there a why to tell if the contact has HOME or WORK email?
Hey,
I try to use your library but unfortunatly the onActivityResult is not called 😞
Here is my MainActivity.java on gist.
I hope you could help me.
Thanks
PS: I kind of new with Android so I look on forums but didn't find the answer.
Antoine
Hi,
Your library is awesome. But please release new version ASAP.
I need EXTRA_WITH_GROUP_TAB attribute. Tried to build via jitpack.io snapshot but failed with some error.
When I added
dependencies {
compile 'com.1gravity:android-contactpicker:1.4.0'
}
in gradle.build file, following error occurred
Could not find method compile() for arguments [com.1gravity:android-contactpicker:1.4.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Selected contacts gets deselected when you click to see any contact details and return back.
as soon as i add the library to my project, it stops working and i get these errors.
[2017-01-03 21:29:11 - TestCalls] /Users/mac/Documents/workspace/main/res/layout/cp_contact_list.xml:20: error: No resource identifier found for attribute 'rfs_backgroundColor' in package 'com.dobicube.TestCalls'
[2017-01-03 21:29:11 - TestCalls]
[2017-01-03 21:29:11 - TestCalls] /Users/mac/Documents/workspace/main/res/layout/cp_contact_list.xml:20: error: No resource identifier found for attribute 'rfs_textColor' in package 'com.dobicube.TestCalls'
[2017-01-03 21:29:11 - TestCalls]
[2017-01-03 21:29:11 - TestCalls] /Users/mac/Documents/workspace/main/res/layout/cp_contact_list.xml:20: error: Error: No resource found that matches the given name (at 'layout_height' with value '@dimen/list_item_height').
[2017-01-03 21:29:11 - TestCalls]
[2017-01-03 21:29:11 - TestCalls] /Users/mac/Documents/workspace/main/res/layout/cp_contact_tab_layout.xml:9: error: No resource identifier found for attribute 'tabTextColor' in package 'com.dobicube.TestCalls'
[2017-01-03 21:29:11 - TestCalls]
[2017-01-03 21:29:11 - TestCalls] /Users/mac/Documents/workspace/main/res/layout/cp_contact_tab_layout.xml:9: error: No resource identifier found for attribute 'tabSelectedTextColor' in package 'com.dobicube.TestCalls'
[2017-01-03 21:29:11 - TestCalls]
Attached are the project and library's properties, not sure what i did wrong here, oh and the Demo app won't work either. I would really appreciate some help.
Thanks
I'm not interested with the groups, a option to remove groups would be great !
I'm looking to integrate this picker in an existing app, so I'd like to match its style. Is there an example of how to create custom styles?
It would be good to have sources or accounts information along with groups and contacts information
So that it can be differentiate if 2 groups have the same name they can be known by their accounts/sources
I have follow your instruction and i got this toast menu instead of Contact Layout with ContactPickerActivity.
1 :- My Dependencies are
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.1gravity:android-contactpicker:1.3.1'
testCompile 'junit:junit:4.12'
}
2 :- My AndroidMenifest.xml file
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />/>
</intent-filter>
</activity>
<activity
android:name="com.onegravity.contactpicker.core.ContactPickerActivity"
android:enabled="true"
android:exported="false" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
3 :- My MainActivity.java
package com.example.the_king.findnotification;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Path;
import android.os.Build;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.onegravity.contactpicker.contact.Contact;
import com.onegravity.contactpicker.contact.ContactDescription;
import com.onegravity.contactpicker.contact.ContactSortOrder;
import com.onegravity.contactpicker.core.ContactPickerActivity;
import com.onegravity.contactpicker.group.Group;
import com.onegravity.contactpicker.picture.ContactPictureType;
import java.util.List;
import static com.example.the_king.findnotification.R.style.ContactPicker_Theme_Light;
public class MainActivity extends AppCompatActivity {
private Button mybtn;
public boolean mDarkTheme;
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mybtn = (Button)findViewById(R.id.mybtn);
mybtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OpenContact();
}
});
}
public void OpenContact(){
boolean res = askPermission(0);
if(res==true){
startIntent();
}
}
public void startIntent(){
Intent intent = new Intent(this, ContactPickerActivity.class).putExtra(ContactPickerActivity.EXTRA_THEME,ContactPicker_Theme_Light).putExtra(ContactPickerActivity.EXTRA_CONTACT_BADGE_TYPE, ContactPictureType.ROUND.name()).putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION, ContactDescription.ADDRESS.name()).putExtra(ContactPickerActivity.EXTRA_SHOW_CHECK_ALL, true).putExtra(ContactPickerActivity.EXTRA_SELECT_CONTACTS_LIMIT, 0).putExtra(ContactPickerActivity.EXTRA_ONLY_CONTACTS_WITH_PHONE, false).putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION_TYPE, ContactsContract.CommonDataKinds.Email.TYPE_WORK).putExtra(ContactPickerActivity.EXTRA_CONTACT_SORT_ORDER, ContactSortOrder.AUTOMATIC.name());
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0 && resultCode == Activity.RESULT_OK &&
data != null && data.hasExtra(ContactPickerActivity.RESULT_CONTACT_DATA)) {
// we got a result from the contact picker
// process contacts
List<Contact> contacts = (List<Contact>) data.getSerializableExtra(ContactPickerActivity.RESULT_CONTACT_DATA);
for (Contact contact : contacts) {
// process the contacts...
}
// process groups
List<Group> groups = (List<Group>) data.getSerializableExtra(ContactPickerActivity.RESULT_GROUP_DATA);
for (Group group : groups) {
// process the groups...
}
}
}
//asking permission from the user to access to contact
public boolean askPermission(int identification){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
if(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.READ_CONTACTS},identification);
return false;
}
else{
return true;
}
}else{
return true;
}
}
//Accordng to the permission result back and perform what data is selected from the user
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode){
case 0:
if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
}else{
Toast.makeText(this,"Go Directive wants to access permission..Please give to access permission by click on + -> allow",Toast.LENGTH_LONG).show();
}
break;
case 1:
if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
}else{
Toast.makeText(this,"Go Directive wants to access permission..Please give to access permission by click on + -> allow",Toast.LENGTH_LONG).show();
}
break;
}
}
}
4 :- activity_main.xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mybtn"
android:text="Contact"
/>
Can you suggest me any solution which solve this problem?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.materialdesigncodelab, PID: 6260
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.materialdesigncodelab/com.onegravity.contactpicker.core.ContactPickerActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.design.widget.TabLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.design.widget.TabLayout
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.support.design.widget.TabLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at com.onegravity.contactpicker.core.ContactPickerActivity.onCreate(ContactPickerActivity.java:298)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 9: TypedValue{t=0x2/d=0x7f010135 a=-1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:528)
at android.support.design.widget.TabLayout.(TabLayout.java:341)
at android.support.design.widget.TabLayout.(TabLayout.java:290)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
at com.onegravity.contactpicker.core.ContactPickerActivity.onCreate(ContactPickerActivity.java:298)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Hi in my project i need to pickup only 5 contacts at a time?is it possible to do?Once we reach the limit then contact should not be selected, it should auto unchecked and alert should display?Please guide me.
Hi,
I want to use your Contact Picker Library in my project. We need the details of the picked contact by the user with the photo path of the contact. But the library always returns null in photoUri for all contacts (with photo and without photo).
Please let me know how we can able to get the photos for the picked contact.
One more things, we only want to show the contacts (in the list) that have at least one phone number. How we can achieve this.
Thanks in advance.
Any way of translating the text (search etc)
getPhone(0) returning blank result @lwhiteley @1gravity @vazbloke @LeonardooBorges @dshatz
Have you consider making ContactImpl.mEmail and ContactImpl.mPhone accessible form Contact interface level?
API getEmail(type) is really hard to use when we want to get all the emails/phones. Adding getEmails/getPhones methods would have solved a problem.
Whenever i try to select all contacts and click on the done button the screen turn black and the application is unresponsive.
There is no error the applications just stops responding.
it doesn't get back to the parent activity from which the library was called.
Hi!
It possibile obtain from a Contact his website, note and company?
Thanks in advice
i am able to display name but i cant able to send message with selected name is there any way to show only number instead of name.
I can't get the contact picker to retain contacts I have selected before.
I've collected all the selected contacts id into a serializable arraylist like this:
private ArrayListpreSelectedContacts;
preSelectedContacts=new ArrayList();
preSelectedContacts.add(cp.getString(cp.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID)));
What can I do?
Hi there,
I am using Android-ContactPicker and enjoying it really! Thanks very much 👍 . Sometimes over Firebase I get the following Exception. I am using 1.3.2:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToFirst()' on a null object reference
at com.onegravity.contactpicker.core.ContactPickerActivity.readContacts(ContactPickerActivity.java:603)
at com.onegravity.contactpicker.core.ContactPickerActivity.onLoadFinished(ContactPickerActivity.java:551)
at com.onegravity.contactpicker.core.ContactPickerActivity.onLoadFinished(ContactPickerActivity.java:69)
at androidx.loader.app.LoaderManagerImpl$LoaderObserver.onChanged(LoaderManagerImpl.java:250)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:131)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:149)
at androidx.lifecycle.LiveData.setValue(LiveData.java:307)
at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
at androidx.loader.app.LoaderManagerImpl$LoaderInfo.setValue(LoaderManagerImpl.java:189)
at androidx.loader.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManagerImpl.java:174)
at androidx.loader.content.Loader.deliverResult(Loader.java:132)
at androidx.loader.content.CursorLoader.deliverResult(CursorLoader.java:109)
at androidx.loader.content.CursorLoader.deliverResult(CursorLoader.java:41)
at androidx.loader.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:258)
at androidx.loader.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:83)
at androidx.loader.content.ModernAsyncTask.finish(ModernAsyncTask.java:490)
at androidx.loader.content.ModernAsyncTask$InternalHandler.handleMessage(ModernAsyncTask.java:507)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:215)
at android.app.ActivityThread.main(ActivityThread.java:6939)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Firstly I tested it on a device having 700 contacts, It worked fine but a device with 1500 contacts shows some issues. When a contact list activity is opened, and when you scroll down, the activity hangs and crashes after few seconds. Did you find this behavior?
Have you implemented pagination for the contacts?
Whenever the selected contacts are about 20 and above, only about half of the contacts get passed to the results string. Behavior has been observed repeatedly as the app is already in production
I'm using this libray in my app, but recently it started to crash with this exception:
java.lang.NoSuchMethodError: No virtual method setOnTabSelectedListener(Landroid/support/design/widget/TabLayout$OnTabSelectedListener;)V in class Landroid/support/design/widget/TabLayout; or its super classes (declaration of 'android.support.design.widget.TabLayout' appears in /data/app/com.xxxxx.xxxx-YL97fZYcIM1aCE1xeiou9g==/split_lib_dependencies_apk.apk)
at com.onegravity.contactpicker.core.ContactPickerActivity.onCreate(ContactPickerActivity.java:357)
This seems to have to do with this post: https://stackoverflow.com/questions/38498788/setontabselectedlistener-is-deprecated
Unfortunately I do not have the time to investigate this any further at the moment.
Can i use it with Autocomplete textview? that would be more appropriate right?
Hi
Is it possible to filter which contacts are retrieved from the backend? Specifically, I'm interested in showing only contacts that have a cell phone number.
Thanks and Kind Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.