You could try Traceview and see where the time is going:

http://developer.android.com/guide/developing/tools/traceview.html

On Sat, Oct 9, 2010 at 5:32 PM, Streets Of Boston
<[email protected]> wrote:
> Thank you Dianne,
> I'll make sure to use the inheritance.
>
> But why is it so much faster when not inheriting, not using
> '"parent="android:Theme"'?
>
> When using style-inheritance properly:
> In the beginning i also thought that my code was the slow part in
> starting up and preventing a quick initial drawing of the activity's
> content-view.
>
> However, I put tons of timing statements in (e.g. i time the onCreate
> begins and ends and the system's calls to onResume, onStart,
> onPostResume, etc). All the timing statements indicate that onCreate
> finishes timely, onPostCreate, onResume, etc. are all called and
> finished in a timely manner.
>
> I see the last timing statement (log of 'onCreateStartTime-
> System.currentMillis()') in my onResume() implementation in the log,
> which appears quickly, in a timely manner. Then the activity just sits
> there for 0.5 - 2 seconds showing the theme's background without the
> activity's content. After the 0.5 - 2 seconds, the content shows up.
>
> I just can't figure out what happens between after the call to
> onResume and the appearance of the activity's content.... and why it
> is slow, even for an activity with hardly any content (a few text-
> fields, that's all, no large intent-data either).
>
> Thanks!
>
>
>
> On Oct 8, 7:05 pm, Dianne Hackborn <[email protected]> wrote:
>> First, a theme MUST inherit from one of the standard ones.  If it doesn't,
>> some things won't work now, some things will break in the future, etc.
>>
>> When an app is being launched for the first time, a preview of it is first
>> shown by constructing a window with the theme from its manifest and showing
>> that.  The delay from when that empty window is shown until the actual app
>> is faded in is the time it is taking your app to launch.  If you want to
>> reduce that, you need to profile and optimize your app's launch time.
>>
>> On Fri, Oct 8, 2010 at 3:50 PM, Streets Of Boston
>> <[email protected]>wrote:
>>
>>
>>
>>
>>
>> > When i create an activity that uses a custom-theme, e.g.
>> > android:theme="@style/MyLogonTheme".
>>
>> > I create my theme in styles.xml:
>>
>> > <style name="MyLogonTheme" parent="android:Theme">
>> >    <item name="android:typeface">sans</item>
>> >    <item name="android:windowBackground">@drawable/
>> > android_screen_logon_bg</item>
>> > </style>
>>
>> > (note that i have a few more themes and plenty more styles in
>> > styles.xml, but they are not in use for this particular activity).
>>
>> > When the activity is started brand new (e.g. after the process has
>> > just started), it starts VERY slowly:
>> > 1. The background (windowBackground) appears quickly, in a timely
>> > manner and the activity's 'setContentView' is called almost
>> > immediately in the onCreate.
>> > 2. However, the activity's content-view (setContentView) finally shows
>> > up 0.5 - 2 seconds later (depending on the speed of the phone)!
>>
>> > When i remove the 'parent' from MyLogonTheme's definition:
>> > <style name="MyLogonTheme">
>> >    <item name="android:typeface">sans</item>
>> >    <item name="android:windowBackground">@drawable/
>> > android_screen_logon_bg</item>
>> > </style>
>> > Both the background and the content-view appear quickly!
>>
>> > Somehow, including the inheritance from the "android:Theme" slows
>> > things down quite considerably.
>>
>> > Why is this the case?
>> > Is there a way around it?
>>
>> > I looked at the log... no special output that may indicate
>> > something... it is just slow.
>>
>> > BTW:
>> > If i do remove the parent="android:Theme" part, things do load/show
>> > quickly, but i get quite a few warnings in the log. The warnings
>> > complain about layout_height is missing and some ColorStateList with
>> > TypedValue (0x2/0x1010059 a=-1) can not be found. They are just
>> > warnings... i see no other side effects.
>> > If i specify the parent="android:Theme", I don't get these warnings.
>>
>> > Can I just remove the parent="android:Theme" part and live with the
>> > warnings?
>>
>> > Thanks!
>>
>> > --
>> > 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%2bunsubs­[email protected]>
>> > For more options, visit this group at
>> >http://groups.google.com/group/android-developers?hl=en
>>
>> --
>> 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, and so won't reply to such e-mails.  All such
>> questions should be posted on public forums, where I and others can see and
>> answer them.- Hide quoted text -
>>
>> - Show quoted text -
>
> --
> 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
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

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