3

I've done a lot of googling over the days and I haven't been able to get this problem solved. I'm writing an app and a widget in which I want the quick contact dialog displayed when the user clicks on an ImageView or some other view element by calling QuickContact.showQuickContact(). For some reason, every time I try on Eclair, I get the following error thrown:

01-02 17:51:28.869: ERROR/AndroidRuntime(657): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sx.favwidget/com.sx.favwidget.PopupActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.contacts.action.QUICK_CONTACT dat=content://com.android.contacts/contacts/lookup/0n4D29415739 flg=0x14200000 (has extras)

(I left out the rest of the logcat, but I can put it back if you guys need it)

When I try the exact same code on Froyo, it just works. I don't want to have my app targeted only for Froyo users - I'm targeting 2.1 as the minimum OS level. I've found some other people on Stack Overflow struggling with getting QuickContacts to display.

I could use a QuickContactBadge, and that does work on Eclair, but I'm not allowed a QuickContactBadge in an AppWidget, so I have do this instead. I dug through Android's source code and found the relevant XML files and code for creating the layout but I can't just easily compile it myself because it's a huge headache with all the private API calls.

Here is my code. It's simple.

grid.setOnItemClickListener(new OnItemClickListener() {

    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

        String name = ((TextView)v.findViewById(R.id.grid_item_label)).getText().toString();

        Cursor sc = getContentResolver().query(Contacts.CONTENT_URI, new String[] {Contacts.LOOKUP_KEY,   Contacts._ID}, Contacts.DISPLAY_NAME + "= ?", new String[] {name}, null);

        sc.moveToFirst();          

        String lookup_key = sc.getString(sc.getColumnIndex(Contacts.LOOKUP_KEY));

        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookup_key);

        QuickContact.showQuickContact(getApplicationContext(), v, uri, QuickContact.MODE_SMALL, null);

        }
}

It's just so strange that it works on Froyo, not Eclair, but the API call has been there since Android 2.0. Can anyone help me here??

Thanks so much!!!

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
Sam
  • 41
  • 3

1 Answers1

1

I solved this as well some time ago but forgot to post how. What I did was launch a new activity that was transparent, and I got the rectangle from which the intent was launched. This activity had only a QuickContactBadge element, so I positioned it using the rectangle and performed a click action automatically on it. Once this was displayed, I finished the activity - but the badge remains. Therefore, when the person clicked out of the QuickContactBadge, they'd be right back to where they started.

I didn't get a chance to peruse your (Omegamon) code thoroughly - is your method similar to mine?

Sam
  • 41
  • 3
  • It's also worth noting that this is the same method Android uses to show its QuickContacts. After writing all the code, I looked through the source code again and found a comment (which I'm surprised I didn't notice before) saying how this was actually the current workaround until framework support is built. – Sam Aug 18 '11 at 04:09