Hi All,

Just make clear of my question: is there an open source plugin for account
management and contact sync for facebook in Andorid? Thanks a lot.

James

2009/12/5 Zhihong GUO <[email protected]>

> Hi all,
>
> I am wandering if there is any examples on the account and sync plugin in
> Android Open Source project. For example, if there are any code on Facebook
> plugin in contacts and sync. If not, can any one help me give the codes in
> Eclair contacts and email application related to the topic.
> Thanks
> James
>
> 2009/12/3 Jerry Brady <[email protected]>
>
> The droids run 2.0, but the published Eclair source is 2.1 and that
>> was the fastest way to get an emulator that included the "Accounts &
>> Sync" settings that isn't in the 2.0 emulator.  AFAIK you'll need that
>> in order to affect any testing that will work on shipping 2.0 devices.
>>
>> I don't have time to look into this any further at the moment as I'm
>> currently looking into the *next* issue which is the way in which the
>> contacts application handles contacts from account sources other than
>> the built-in Google and Exchange sources...
>>
>> Cheers,
>> Jerry
>>
>> On Dec 1, 8:02 pm, Dan Dumont <[email protected]> wrote:
>> > Drat...    I don't want to build 2.1...   I thought the droids ran 2.0?
>> >
>> > anyway...    I updated the project.   Please let me know if it works :)
>>   I
>> > get an error still in the 2.0 emulator...
>> > 12-01 19:54:36.454: ERROR/AndroidRuntime(93):
>> > android.content.ActivityNotFoundException: No Activity found to handle
>> > Intent { act=android.settings.SYNC_SETTINGS (has extras) }
>> >
>> >
>> >
>> > On Tue, Dec 1, 2009 at 4:18 PM, Dan Dumont <[email protected]> wrote:
>> > > I'll update my project asap!    Thanks for looking into this!!
>> >
>> > > when we create the binder, do we need to verify that the "account"
>> variable
>> > > is for us?   IE... will the intent be triggered for all providers, and
>> we
>> > > must figure out if the info is our or not?
>> >
>> > > On Mon, Nov 30, 2009 at 2:35 PM, Jerry Brady <[email protected]
>> >wrote:
>> >
>> > >> Guys following this issue,
>> >
>> > >> I found the ultimate cause of the error and found a workaround that
>> > >> will allow you to work on a Droid.
>> >
>> > >> One thing that's helpful is building yourself an Eclair 2.1 SDK so
>> you
>> > >> can use an emulator (2.1) that includes the "Accounts & Sync"
>> settings
>> > >> option we need in working with accounts:
>> >
>> > >> -------------------------------------
>> > >> From the the root of the android source tree:
>> > >> . build/envsetup.sh
>> > >> lunch sdk-eng
>> > >> make sdk (may want to use -j<something> based on your number of
>> cores)
>> >
>> > >> find the SDK in out/host/linux/sdk/...
>> >
>> > >> From the SDK, copy platforms/android-#.# into your SDK/platform on
>> > >> your destination pc.
>> >
>> > >> If that's running windows, copy platforms/android-2.0/tools/* into
>> > >> your newly created platforms tools folder.
>> >
>> > >> Use the AVD Manager to create an AVD for this new platform.
>> > >> -----------------------------------------------
>> >
>> > >> The crash is caused by an undocumented assumption in the Android code
>> > >> that handles accounts and sync.  They are *very* closely related.  It
>> > >> turns out that the "Accounts and Sync" settings plugin after getting
>> > >> the accounts on the system, uses the content service to scan for
>> > >> services on the system that implement the intent
>> > >> "android.content.SyncAdapter".
>> >
>> > >> Since our code doesn't implement this, the search came up empty
>> handed
>> > >> and since the code assumed this would never happen, BAM, null pointer
>> > >> exception and crash.
>> >
>> > >> It turns out that the solution is to have your application (or
>> > >> something on the system) implement a service that catches the intent
>> > >> "android.content.SyncAdapter" that returns an IBinder to an object
>> > >> that extends AbstractThreadedSyncAdapter (just like we did for our
>> > >> AbstractAccountAuthenticator).
>> >
>> > >> I took examples from the source code for the Email application in
>> > >> android, but here are the relevant bits to setup an empty sync
>> adapter
>> > >> for contacts that does nothing but gets you past the exception:
>> >
>> > >> AndroidManifest.xml:
>> >
>> > >>
>> ---------------------------------------------------------------------------
>> -
>> > >> <!--Required stanza to register the ContactsSyncAdapterService with
>> > >> SyncManager -->
>> > >> <service
>> > >> android:name="com.YOURDOMAIN.YOURAPP.ContactsSyncAdapterService"
>> > >>             android:exported="true">
>> > >>    <intent-filter>
>> > >>        <action android:name="android.content.SyncAdapter" />
>> > >>    </intent-filter>
>> > >>        <meta-data android:name="android.content.SyncAdapter"
>> > >>                   android:resource="@xml/syncadapter_contacts" />
>> > >> </service>
>> >
>> > >> xml/syncadapter_contacts - :
>> >
>> > >>
>> ---------------------------------------------------------------------------
>> -----
>> > >> <sync-adapter xmlns:android="http://schemas.android.com/apk/res/
>> > >> android"
>> > >>    android:contentAuthority="com.android.contacts"
>> > >>    android:accountType="com.YOURDOMAIN.YOURAPP"
>> > >> />
>> >
>> > >> ContactSyncAdapter:
>> > >> =====================================
>> > >> public class ContactsSyncAdapterService extends Service {
>> > >>        private static final String TAG =
>> "ContactsSyncAdapterService";
>> > >>        private static SyncAdapterImpl sSyncAdapter = null;
>> > >>        private static final Object sSyncAdapterLock = new Object();
>> >
>> > >>        public ContactsSyncAdapterService() {
>> > >>                super();
>> > >>        }
>> >
>> > >>    private static class SyncAdapterImpl extends
>> > >> AbstractThreadedSyncAdapter {
>> > >>        private Context mContext;
>> >
>> > >>        public SyncAdapterImpl(Context context) {
>> > >>                super(context, true /* autoInitialize */);
>> > >>                mContext = context;
>> > >>        }
>> >
>> > >>        @Override
>> > >>        public void onPerformSync(Account account, Bundle extras,
>> > >>                        String authority, ContentProviderClient
>> provider,
>> > >> SyncResult syncResult) {
>> > >>                try {
>> > >>
>>  ContactsSyncAdapterService.performSync(mContext,
>> > >> account,
>> > >> extras,
>> > >>                                authority, provider, syncResult);
>> > >>                } catch (OperationCanceledException e) {
>> > >>                }
>> > >>        }
>> > >>        }
>> >
>> > >>    @Override
>> > >>    public void onCreate() {
>> > >>        super.onCreate();
>> > >>        synchronized (sSyncAdapterLock) {
>> > >>            if (sSyncAdapter == null) {
>> > >>                sSyncAdapter = new SyncAdapterImpl
>> > >> (getApplicationContext());
>> > >>            }
>> > >>        }
>> > >>    }
>> >
>> > >>    @Override
>> > >>     public IBinder onBind(Intent intent) {
>> > >>         return sSyncAdapter.getSyncAdapterBinder();
>> > >>    }
>> >
>> > >>    private static void performSync(Context context, Account account,
>> > >> Bundle extras,
>> > >>            String authority, ContentProviderClient provider,
>> > >> SyncResult syncResult)
>> > >>            throws OperationCanceledException {
>> > >>        ContentResolver cr = context.getContentResolver();
>> > >>        Log.i(TAG, "performSync: " + account.toString());
>> > >>     }
>> > >> }
>> >
>> > >> On Nov 23, 8:46 pm, Dan Dumont <[email protected]> wrote:
>> > >> > Nice, thanks for doing that!    I'll star it, I hope we get a
>> response
>> > >> soon.
>> >
>> > >> > On Mon, Nov 23, 2009 at 5:32 PM, Jerry Brady <
>> [email protected]>
>> > >> wrote:
>> > >> > > Just filed a case for this:
>> >
>> > >> > >http://code.google.com/p/android/issues/detail?id=5009
>> >
>> > >> > > On Nov 23, 1:47 pm, Jerry Brady <[email protected]> wrote:
>> > >> > > > Dan,
>> >
>> > >> > > > My code and yours both work on the Droid, but there are some
>> nasty
>> > >> > > > side-effects.  After adding an account with your application
>> (or
>> > >> mine)
>> > >> > > > whenever you visit the "Accounts & Sync" settings screen, the
>> system
>> > >> > > > crashes hard and reboots.
>> >
>> > >> > > > 11-23 13:21:34.863: WARN/dalvikvm(1011): threadid=13: thread
>> exiting
>> > >> > > > with uncaught exception (group=0x4001b180)
>> > >> > > > 11-23 13:21:34.863: ERROR/AndroidRuntime(1011): Uncaught
>> handler:
>> > >> > > > thread android.server.ServerThread exiting due to uncaught
>> exception
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): *** EXCEPTION
>> IN
>> > >> > > > SYSTEM PROCESS.  System will crash.
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):
>> > >> > > > java.lang.NullPointerException
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):     at
>> > >> > > > com.android.settings.ManageAccountsSettings.onSyncStateUpdated
>> > >> > > > (ManageAccountsSettings.java:187)
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):     at
>> > >> > > > com.android.settings.ManageAccountsSettings.onAccountsUpdated
>> > >> > > > (ManageAccountsSettings.java:244)
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):     at
>> > >> > > > android.accounts.AccountManager$10.run(AccountManager.java:389)
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):     at
>> > >> > > > android.os.Handler.handleCallback(Handler.java:587)
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):     at
>> > >> > > > android.os.Handler.dispatchMessage(Handler.java:92)
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):     at
>> > >> > > > android.os.Looper.loop(Looper.java:123)
>> > >> > > > 11-23 13:21:34.879: ERROR/AndroidRuntime(1011):     at
>> > >> > > > com.android.server.ServerThread.run(SystemServer.java:428)
>> >
>> > >> > > > I'm looking at the source now to see if I can figure out what's
>> > >> going
>> > >> > > > on.  If necessary, I'll file a case with the project if I find
>> a bug
>> > >> > > > in the Android source.
>> >
>> > >> > > > Cheers,
>> > >> > > > Jerry
>> >
>> > >> > > > On Nov 23, 8:18 am, Jerry Brady <[email protected]> wrote:
>> >
>> > >> > > > > I'm going to be trying it on a Droid this morning.
>> >
>> > >> > > > > On Nov 21, 10:07 pm, Dan Dumont <[email protected]> wrote:
>> >
>> > >> > > > > > I get that exception in the emulator ( doesn't reboot
>> though )
>> >
>> > >> > > > > > I thought it was due to missing pieces of the emulator...
>> >
>> > >> > > > > >  does logcat output anything?
>> >
>> > >> > > > > > On Sat, Nov 21, 2009 at 7:07 PM, NitroDesk <
>> [email protected]>
>> > >> > > wrote:
>> > >> > > > > > > Any of you folks tried this on a Droid?
>> > >> > > > > > > Simply installing the project that contains an
>> Authenticator
>> > >> in the
>> > >> > > > > > > manfest and the other related items seems to cause the
>> "Add
>> > >> > > Account"
>> > >> > > > > > > option in the account list on te droid to simply reoot
>> the
>> > >> phone
>> > >> > > with
>> > >> > > > > > > an exception.
>> > >> > > > > > > Anyone else seen this or find a way to avoid this ?
>> > >> > > > > > > -g
>> >
>> > >> > > > > > > On Nov 21, 9:04 am, Jerry Brady <[email protected]>
>> > >> wrote:
>> > >> > > > > > > > Dan,
>> >
>> > >> > > > > > > > Now I see what you are doing in your code and found the
>> > >> reference
>> > >> > > to
>> > >> > > > > > > > AddAccountExplicitly().   I want to skip returning an
>> intent
>> > >> to
>> > >> > > fire
>> > >> > > > > > > > the an AccountAuthenticatorActivity and instead to
>> return
>> > >> > > > > > > > KEY_ACCOUNT_NAME and KEY_ACCOUNT_TYPE directly from my
>> > >> > > > > > > > AbstractAccountAuthenticator's addAccount method
>> whereas
>> > >> your
>> > >> > > code
>> > >> > > > > > > > returns an intent that fires your authentication
>> activity.
>> >
>> > >> > > > > > > > The main issue for me so far is that I...
>> >
>> > read more ยป
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<android-developers%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to