Search code examples
androidandroid-3.0-honeycomb

Setting a theme/style when using startActivity()


Simple question:

I am using PICK_CONTACT in my Android 3.0 application. The issue is that the contact app has a light theme while my app uses a dark one.

So the question is:

Is there a way to set a style/theme when using startActivity()?

If I am creating my own library and I want the user to be able to use customize styles, I will need to receive something in the intent? Is there a better way to solve this?


Solution

  • Is there a way to set a style/theme when using startActivity()?

    No. You have no right to mess with other apps' user interfaces, any more than they have a right to mess with yours.

    In the case of PICK_CONTACT, if you are willing to have the READ_CONTACTS permission, there is nothing stopping you from writing your own contact picker activity, themed as you wish.

    If I am creating my own library and I want the user to be able to use customize styles, I will need to receive something in the intent?

    Since there is no setStyle() method, dynamically changing an activity's style seems troublesome.

    If your library will be shipped as an Android library project, you can provide theme resources and guidance for developers who, when adding your activities to their manifest, can choose which theme to use at compile time.