More forcefully -- we can pretty much guarantee you will break in the future
if you use reflection.  If nothing else, there is a good chance that a lot
of the search UI will be moved to another process so the implementation you
would have been poking just won't be there any more.

On Thu, Feb 12, 2009 at 6:38 PM, Andrew Stadler <[email protected]> wrote:

>
> Hello Marty,
>
> Unfortunately, the search dialog was not designed to be extended in
> this way.  This was not meant to "protect" it so much as a consequence
> of the data-driven design of the Search system.
>
> If you can describe some of the changes you have in mind, perhaps we
> can assist with some good suggestions.
>
> *Please* don't try to hack into it via reflection.  We cannot
> guarantee compatibility across multiple phone software versions.
>
> Andy Stadler (Google)
>
>
> On Mon, Feb 9, 2009 at 7:07 PM, Marty Wang <[email protected]> wrote:
> >
> > Hi Android folks,
> >
> > We currently want to customize the default Android search dialog UI to
> > have our own look&feel. After looking into Android source code, we
> > found out that two things of Android preventing us from doing it.
> >
> > 1. SearchManager declares an instance of SearchDialog as one of its
> > private fields
> > 2. SearchDialog is not compiled into the SDK. We are using 1.0R2.
> >
> > As for problem 1, we actually could work it around by reflection. The
> > following is our code snippet to expose the private search dialog
> > field of SearchManager
> >
> >                                SearchManager searchManager =
> > (SearchManager)getSystemService(Context.SEARCH_SERVICE);
> >
> >                                try
> >                                {
> >                                        Class<?> searchManagerClass =
> > searchManager.getClass();
> >                                        Field searchDialogField =
> > searchManagerClass.getDeclaredField("mSearchDialog");
> >                                        searchDialogField.setAccessible
> > (true);
> >                                        searchDialogField.set
> > (searchManager, new OurCustomSearchDialog(context));
> >                                } catch (SecurityException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                } catch (NoSuchFieldException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                } catch (IllegalArgumentException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                } catch (IllegalAccessException e)
> >                                {
> >                                        // TODO Auto-generated catch
> > block
> >                                        e.printStackTrace();
> >                                }
> > However, when the code comes to the line
> >
> > searchDialogField.set(searchManager, new OurCustomSearchDialog
> > (context));,
> >
> > it brings up the second problem. Because SearchDialog is not in the
> > SDK, we have no way to create our custom search dialog by subclassing
> > it. Then the line is actually not possible.
> >
> > Since the approach above cannot achieve our goal, I wonder if any of
> > you guys happen to know how to customize the default Android search
> > dialog, or at least why Google takes measures like that to protect
> > SearchDialog from being customized. Thanks!
> >
> > >
> >
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~
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