Search Results

Search found 41 results on 2 pages for 'contactscontract'.

Page 2/2 | < Previous Page | 1 2 

  • context.getContextResolved appliaction stopped - begginner in java

    - by Szymad
    I have a problem with my app. I'm trying to execute query, but app stops every time. This error occurs while trying to execute query. I'm learing from Android Pro 3 book, but code presented in this book is deprecated. package com.example.contactsabuout; import android.net.Uri; import android.os.Bundle; import android.provider.Contacts; import android.provider.ContactsContract; import android.app.Activity; import android.database.Cursor; import android.util.Log; import android.content.Context; import android.view.Menu; import android.view.View; import android.widget.TextView; public class MainActivity extends Activity { private static Context context; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MainActivity.context = getApplicationContext(); Log.v("INFO", "Completed: onCreate."); } public static Context getAppContext() { return MainActivity.context; } public void doQuery(View view) { Uri peopleBaseUri = ContactsContract.Contacts.CONTENT_URI; Log.v("II","Button clicked."); Log.v("II", "Uri for ContactsContract.Contacts: " + peopleBaseUri); Context context = getAppContext(); Log.v("II", "Got context: " + context); Cursor cur; Log.v("II", "Created cursor: cur"); cur = context.getContentResolver().query(peopleBaseUri, null, null, null, null); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } FROM LogCat 10-28 17:45:02.513: V/INFO(4677): Completed: onCreate. 10-28 17:45:02.613: D/libEGL(4677): loaded /system/lib/egl/libGLES_android.so 10-28 17:45:02.653: D/libEGL(4677): loaded /system/lib/egl/libEGL_adreno200.so 10-28 17:45:02.723: D/libEGL(4677): loaded /system/lib/egl/libGLESv1_CM_adreno200.so 10-28 17:45:02.723: D/libEGL(4677): loaded /system/lib/egl/libGLESv2_adreno200.so 10-28 17:45:03.014: I/Adreno200-EGLSUB(4677): <ConfigWindowMatch:2078>: Format RGBA_8888. 10-28 17:45:03.054: D/OpenGLRenderer(4677): Enabling debug mode 0 10-28 17:45:03.254: D/OpenGLRenderer(4677): has fontRender patch 10-28 17:45:03.274: D/OpenGLRenderer(4677): has fontRender patch 10-28 17:45:12.873: V/II(4677): Button clicked. 10-28 17:45:12.873: V/II(4677): Uri for ContactsContract.Contacts: content://com.android.contacts/contacts, rest will be null 10-28 17:45:12.873: V/II(4677): Got context: android.app.Application@40d83d90 10-28 17:45:12.873: V/II(4677): Created cursor: cur 10-28 17:45:12.933: D/AndroidRuntime(4677): Shutting down VM 10-28 17:45:12.933: W/dalvikvm(4677): threadid=1: thread exiting with uncaught exception (group=0x40aaf228) 10-28 17:45:12.953: E/AndroidRuntime(4677): FATAL EXCEPTION: main 10-28 17:45:12.953: E/AndroidRuntime(4677): java.lang.IllegalStateException: Could not execute method of the activity 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.view.View$1.onClick(View.java:3071) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.view.View.performClick(View.java:3538) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.view.View$PerformClick.run(View.java:14330) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.os.Handler.handleCallback(Handler.java:608) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.os.Handler.dispatchMessage(Handler.java:92) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.os.Looper.loop(Looper.java:156) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.app.ActivityThread.main(ActivityThread.java:4977) 10-28 17:45:12.953: E/AndroidRuntime(4677): at java.lang.reflect.Method.invokeNative(Native Method) 10-28 17:45:12.953: E/AndroidRuntime(4677): at java.lang.reflect.Method.invoke(Method.java:511) 10-28 17:45:12.953: E/AndroidRuntime(4677): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 10-28 17:45:12.953: E/AndroidRuntime(4677): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 10-28 17:45:12.953: E/AndroidRuntime(4677): at dalvik.system.NativeStart.main(Native Method) 10-28 17:45:12.953: E/AndroidRuntime(4677): Caused by: java.lang.reflect.InvocationTargetException 10-28 17:45:12.953: E/AndroidRuntime(4677): at java.lang.reflect.Method.invokeNative(Native Method) 10-28 17:45:12.953: E/AndroidRuntime(4677): at java.lang.reflect.Method.invoke(Method.java:511) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.view.View$1.onClick(View.java:3066) 10-28 17:45:12.953: E/AndroidRuntime(4677): ... 11 more 10-28 17:45:12.953: E/AndroidRuntime(4677): Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.HtcContactsProvider2 uri content://com.android.contacts/contacts from pid=4677, uid=10155 requires android.permission.READ_CONTACTS 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.os.Parcel.readException(Parcel.java:1332) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:182) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.content.ContentProviderProxy.query(ContentProviderNative.java:406) 10-28 17:45:12.953: E/AndroidRuntime(4677): at android.content.ContentResolver.query(ContentResolver.java:315) 10-28 17:45:12.953: E/AndroidRuntime(4677): at com.example.contactsabuout.MainActivity.doQuery(MainActivity.java:47) 10-28 17:45:12.953: E/AndroidRuntime(4677): ... 14 more I'm trying to learn android.

    Read the article

  • Why my buttons OnClick event fails to fire?

    - by Pentium10
    I have an activity, where the ListView holds customized linear layout elements for each row. One of the rows has a button defined as: <Button android:text="Pick a contact" android:id="@+id/btnPickContact" android:layout_width="wrap_content" android:gravity="center_vertical" android:layout_height="wrap_content"></Button> Then in java, I have this code: ((Button) row.findViewById(R.id.btnPickContact)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); intent.putExtra(EXTRA_ONLINE_ID, (String)v.getTag(TAG_ONLINE_ID)); act.startActivityForResult(intent, PICK_CONTACT); } }); In this setup the event fails to start. Also I've tried by implementing the interface: @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); intent.putExtra(EXTRA_ONLINE_ID, (String)v.getTag(TAG_ONLINE_ID)); startActivityForResult(intent, PICK_CONTACT); } still no luck, the event doesn't fire. What to do?

    Read the article

  • Get contact name from just the number

    - by user1190019
    Say i have an edit text and a button. In the edit text you would type a number and then when you hit the button it will either show the contact information or return with the name of that contact. I have tried all sorts of methods provided with no luck. The one i have successfully gotten the furthest with was the following... But i had no luck returning the name. Cursor phoneCursor = null; contactList = new HashMap<String,String>(); try{ Uri uContactsUri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; String strProjection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME; phoneCursor = getContentResolver().query(uContactsUri, null, null, null, strProjection); phoneCursor.moveToFirst(); String name = ""; String phoneNumber = ""; int nameColumn = phoneCursor.getColumnIndex(Phone.DISPLAY_NAME); int phoneColumn = phoneCursor.getColumnIndex(Phone.NUMBER); phoneCursor.moveToNext(); } } catch(Exception e){ Log.e("[SmsMain] getContactData", e.toString()); } finally{ if(phoneCursor != null){ phoneCursor.close(); phoneCursor = null; } } }

    Read the article

  • how can I get MOBILE phone number from contacts

    - by sungpil yoon
    Hi, I am trying to get mobile phone number from Android contacts. I found several examples using People.NUMBER, but it seems that brings home phone number not MOBILE phone number. I want to accomplish this using old way instead of using ContactsContract. Can somebody show simple code example how this can be done? Thank you very much.

    Read the article

  • How do I use this code to modify contact ringtone in android?

    - by masterkapu
    I found that with code/function I can change the contacts ringtone, but I couldn't find how to use it. Can someone help me, How do I do it? context.getContentResolver().update(contactUri, values, where, args); ContactsContract.Contacts.CUSTOM_RINGTONE One more question. when I call from one android simulator to another I don't hear the ringing sound, what could be the problem?

    Read the article

  • How to start 'View Contact' Activity on android?

    - by Phuc Phan Nguyen Truong
    Hi all, I want to create a tab which contains a tab for viewing contact detail. Here is what i did: intent = new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, ""+contactId)); nativeInfo = tabHost.newTabSpec("native info").setIndicator("N Info").setContent(intent); It throw security exception. I appreciate your help. Thanks.

    Read the article

  • How to read contacts on Android 2.0

    - by appme up
    Hi. I'm working on Android 2.0 and am trying to receive a list of all contacts. Since android.provider.Contacts.People is deprecated, I have to use android.provider.ContactsContract, But I can't find a proper example of how to use it (ex: retrieve a list of all contacts on the phonebook). Anyone knows how to implement it? Thanks!

    Read the article

  • How to display QuickContact card from widget

    - by alejom99
    I have a widget that displays the picture of some of my contacts and I would like to display the QuickContact card when the user taps on one of the pictures. I know I should be using the method ContactsContract.QuickContact.showQuickContact(), but it requires a View or a Rect as one of the input parameters. My problem is that Widgets only have RemoteViews, so I'm no sure what to pass as the View or Rect parameter. Any ideas would be appreciated.

    Read the article

  • remove contact's photo

    - by Varand Tin
    Hey guys, in order to remove contact's photo, which way is correct? 1) to update and set Photo.PHOTO to ""/"NULL" , or 2) to update and set Photo.MIMETYPE to ""/"NULL" or 3) to update and set Data.MIMETYPE to ""/"NULL" ? I wanted to mention also that I insert photos from my app by the following way: cr.insert(ContactsContract.Data.CONTENT_URI, photoValues); Please also tell me "" is better or null? (in updating case) Thanks a lot.

    Read the article

  • android get contact phone number

    - by ng93
    hi, im trying to get a contacts name and phone number from the contacts list. im using: contactname = Curser.getString(Curser.getColumnIndex(Contacts.DISPLAY_NAME)); to get their name and it works fine. But using: contactphone = Curser.getString(Curser.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); causes no warnings or errors and builds fine, yet force closes in both the emulator (2.1) and my htc desire (nexus one 2.2 rom/htc desire 2.1 rom). Any ideas how to fix it? oh and contactname and contactphone are both strings thanks, ng93

    Read the article

  • Need to pick contact from a dialog preference

    - by MLW
    I would like to add a preference setting that uses an ACTION_PICK intent. My goal is to acquire the phone number of a contact in my phone by using a preference. Is this possible? I can run this code from my activity but I discovered I cannot run it from a class that extends DialogPreference. Intent intentContact = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intentContact, PICK_CONTACT); Or is there a way to start a new activity from a preference? Then that activity could execute the above two lines of code?

    Read the article

  • How to add new field(s) to the contact?

    - by user328302
    I want to add a Custom field to the ContactsContract content provider. I'm trying to build a Voip application and would like to add a SIP address(name@domain) field to it. What MIME type will I need to associate with it? Also I want to add a group address field which will have a list of group addresses in it (name@domain, name@domain,...). Wich MIME type will I have to associate with this type of field. I also want to add custom fields to the Call History like a session ID and SIP address(name@domain) field. How can I customize the call history? It'll be great if someone can give me an example.

    Read the article

  • Get company name in android using new API's

    - by HellBoy
    Currently I am getting company name using following code public class ContactsDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Cursor cursor = getContentResolver().query(Contacts.Organizations.CONTENT_URI, null, null, null, null); //ContactsContract.CommonDataKinds. if(cursor!=null){ System.out.println(cursor.getString(cursor.getColumnIndex (Contacts.Organizations.COMPANY))); }}} but I don't want to use deprected API's. & in new API's there is no CONTENT_URI in Organisation class. How to get company name using new API.

    Read the article

  • How to get contacts in order of they upcoming birthdays?

    - by Pentium10
    I have code to read contacts details and to read birthday. But how do I get a list of contacts in order of they upcoming birthday? For a single contact identified by id I get details and birthday like this. Cursor c = null; try { Uri uri = ContentUris.withAppendedId( ContactsContract.Contacts.CONTENT_URI, id); c = ctx.getContentResolver().query(uri, null, null, null, null); if (c != null) { if (c.moveToFirst()) { DatabaseUtils.cursorRowToContentValues(c, data); } } c.close(); // read birthday c = ctx.getContentResolver() .query( Data.CONTENT_URI, new String[] { Event.DATA }, Data.CONTACT_ID + "=" + id + " AND " + Data.MIMETYPE + "= '" + Event.CONTENT_ITEM_TYPE + "' AND " + Event.TYPE + "=" + Event.TYPE_BIRTHDAY, null, Data.DISPLAY_NAME); if (c != null) { try { if (c.moveToFirst()) { this.setBirthday(c.getString(0)); } } finally { c.close(); } } return super.load(id); } catch (Exception e) { Log.v(TAG(), e.getMessage(), e); e.printStackTrace(); return false; } finally { if (c != null) c.close(); }

    Read the article

< Previous Page | 1 2