[android-developers] Proper usage of Fragments + ActionBar

2011-10-19 Thread Sebastian Roth
Hi everyone:

Guess I need some help on how to use the ActionBar in combination with
Fragments.

Simple App Structure:
 Activity A
  Fragment 1
  Fragment 2

Activity A loads, starts Fragment 1. Fragment one contains code to set
the ActionBar:

@Override
public void onResume() {
super.onResume();

ActionBar bar = getSupportActivity().getSupportActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
bar.setListNavigationCallbacks(new
SimpleSpinnerArrayAdapter(getActivity()), this);
}

At some point, Activity A starts Fragment 2, by adding it to the stack
and overlaying. Also, Fragment 2 will revert the ActionBar to the
plain one.

public void showStationList(View view) {
String tag = (String) view.getTag();
if (tag != null && tag.length() > 0) {
FragmentTransaction ft =
getSupportFragmentManager().beginTransaction();
StationListDialog fragment = new StationListDialog(tag.split(","));
ft.add(R.id.f_long_distance, fragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.addToBackStack(null);
ft.commit();
}
}


Problem is: When pressing the back button, means when coming back to
Fragment A, the ActionBar is not restored to the state Fragment A
needs it.

I guess onResume is wrong (as it's not called as well). But I cannot
find the proper place to put this into.

Any suggestion?

Thanks,
Sebastian

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


Re: [android-developers] WifiLock and WakeLock regarding large downloads

2011-03-29 Thread Sebastian Roth
Hold on a second here:

"device policy of shutting down wifi and switching to 3g after 15 minutes of
screen off"

-> that means if I'm at home sleeping (with WiFI enabled), the device will
not use WiFi but 3G over night?

Can you confirm this? Where is this specified?

On Tue, Mar 29, 2011 at 10:41 AM, Irfan Sheriff  wrote:

> WifiLock keeps the device on Wifi and prevents the device policy of
> shutting down wifi and switching to 3g after 15 minutes of screen off.
>
> Holding a wifilock should normally be sufficient to complete a download
> since even in the power optimized state (screen off), the device should
> still wake up on packet reception and they should get handled by the device
> - though the packet loss in screen off state tends to be higher and the
> download will be slower.
>
> If you want to ensure the cpu is awake the whole time, you can hold a
> wakelock as well.
>
> Thanks
>
>
> On Mon, Mar 28, 2011 at 10:31 AM, Mark Carter wrote:
>
>> From what I gather, WifiLock and WakeLock work completely independently
>> and if you are downloading a large file over Wifi then you will need to
>> acquire both locks??
>>
>> Ideally, you would want something like this:
>>
>> 1. Acquire partial WakeLock
>> 2. Preparing to download large file, check whether on Wifi or not.
>> 3. If on Wifi, then acquire WifiLock. If not, then prevent device
>> switching to Wifi (is this possible?)
>> 4. Start download
>> 5. When download has finished, release all locks.
>>
>> Is this correct?
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] android:textAppearance on button

2011-03-21 Thread Sebastian Roth
Hello:

Suppose I have this button:



and a "TextInCallEndCallButton" style:


20sp
#ff
bold


The button color (the text) will stay BLACK.

Now, when I'm setting "android:textColor" directly on the Button, it works.

So, supposed textAppearance is not working, the button label would still be
BOLD and in the specified size of 20sp.

Is this a bug to report or a behavior to avoid?

Android 2.2, HTC Desire.

Thanks!

Sebastian

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

[android-developers] Re: Usage of "android:textAppearence" vs. "style" attributes

2011-03-18 Thread Sebastian Roth
Hi again:

I was mistaken and will close the question soon.

Indeed *textAppearance* works very well. What I did not consider is that the
properties I was using "shadow**" are for the entire element and are not
being considered "text properties", and as such will be ignored when using
"textAppearance".

For the elements noticed in the stackoverflow question, I might simply
haven't seen it as #33 on light gray background looks like black.. sorry
& thx.

BR,
Sebastian

On Thu, Mar 17, 2011 at 11:29 PM, Sebastian Roth
wrote:

> [shamelessly copied from
> http://stackoverflow.com/questions/5337680/using-androidtextappearance-on-textview-edittext-fails-but-style-worksas
>  I believe we have proficient API aware people reading here ;-)]
>
> Hello,
>
> I'm facing a problem that TextView or EditText *text* styling via
> textAppearance doesn't work or only works via the style attribute, which
> isn't useful, if that element in particular is being styled with non-text
> parameters.
>
> In detail, I'm using:
> 
>
> and
> 
>
> whereas styles/MyStyle is defined as :
> 
> <item name="android:textStyle">bold</item>
> 
>
> This will only render the 1st TextView bold, but not the 2nd one.
>
> Do I miss a point in the textAppearance usage here?
>
> Thanks everyone,
> Sebastian
>

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

[android-developers] Usage of "android:textAppearence" vs. "style" attributes

2011-03-17 Thread Sebastian Roth
[shamelessly copied from
http://stackoverflow.com/questions/5337680/using-androidtextappearance-on-textview-edittext-fails-but-style-worksas
I believe we have proficient API aware people reading here ;-)]

Hello,

I'm facing a problem that TextView or EditText *text* styling via
textAppearance doesn't work or only works via the style attribute, which
isn't useful, if that element in particular is being styled with non-text
parameters.

In detail, I'm using:


and


whereas styles/MyStyle is defined as :

bold


This will only render the 1st TextView bold, but not the 2nd one.

Do I miss a point in the textAppearance usage here?

Thanks everyone,
Sebastian

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

Re: [android-developers] SDK 11 is the slowest yet

2011-02-23 Thread Sebastian Roth
Have you tried tuning eclipse.ini options to enable higher memory limits?
Sometimes, if a java app is running 100% it could be related to the garbage
collector collecting (or, trying to) memory all the time.

Else I would try uninstalling unneeded plugins.

BR,
Seb, not an eclipse user anymore

On Wed, Feb 23, 2011 at 5:51 PM, String wrote:

> I was quite pleased this morning to see the official, final release of the
> Honeycomb SDK as level 11, and naturally launched into the (quite lengthy)
> download and install process... only to be really disappointed by the truly
> abysmal performance of the thing.
>
> Every aspect seems to have gotten much, much slower since r10. I mean, I'm
> used (and resigned) to each successive SDK version getting slower, but this
> is an order of magnitude worse than any release before it. The r11 emulator
> is, if anything, even slower than the r10 preview was, but the real problem
> is the ADT in Eclipse. I started a Clean of a medium-sized project before I
> began writing this post, and at this moment, it's still grinding away on it.
> And when it's doing so, Eclipse is essentially unresponsive - I wouldn't
> mind so much if it was just doing its thing in the background, letting me
> get on and do mine, but no. It's just spinning.
>
> My only hope is that this is a bug that made it through into the release. I
> say this because, with r11, my Eclipse process shows as consuming 100% of
> its CPU core all the time, whether it's visibly doing anything or not.
> Xavier, if you're reading this - and I know you often monitor this group
> after an ADT release - please respond.
>
> For the record, I'm running Helios 3.6.1 and Vista Business on dual 2.4GHz
> cores with 4GB RAM.
>
> String
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to delete...?

2011-02-15 Thread Sebastian Roth
On Tue, Feb 15, 2011 at 3:19 PM, Abhilash baddam <
abhilash.androiddevelo...@gmail.com> wrote:
>
> My problem was solved like this..
> myDB.execSQL("DELETE FROM favourites where month=' "+str1+" ' ");
>

Pls. *don't* use this style of writing SQL queries!

JAlexoid (Aleksandr Panzin) had a good suggestion for you.

The reason is "SQL Injection". Pls. have a read here:
http://en.wikipedia.org/wiki/SQL_injection

BR,
Sebastian

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

Re: [android-developers] Re: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

2010-06-24 Thread Sebastian Roth
Hi Kevin:

I think the memory for high megapixel images is not so important because u
usally will stream the image through a InputStream onto disk. You can then
read the image via BitmapFactory and set a inSampleSize to retrieve it.

BR,
Seb, starting up a WIKI for android memory issues..

On Fri, Jun 25, 2010 at 2:32 PM, Kevin Gaudin wrote:

> Hi Romain,
>
> Is there a list somewhere of devices with 24Mb per process ? Is there
> a way to adjust this in the emulator ? Is there an API method allowing
> to know the total memory available for the process ?
>
> I'm writing a pictures manipulating app, and handling hires pics is
> hard with only 16Mb. New devices with high megapixels camera sure need
> more.
>
> Thank you,
>
> Kevin
>
> On 17 juin, 09:33, Romain Guy  wrote:
> > When you get such an error it's because *your* process is running out
> > of memory. Other processes have nothing to do with it. You are using
> > too much memory in your process and blowing past the heap limit (16 MB
> > or 24 MB depending on the device you're using.)
> >
> >
> >
> >
> >
> > On Thu, Jun 17, 2010 at 12:07 AM, Amit  wrote:
> > > Hi
> >
> > > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> > > I am getting this message in my log. As I investigated and found out
> > > while loading contact image this error comes.I checked  size of the
> > > image file and it was normal so came to a conclusion that other
> > > processes filling up the memory and hence at the time this image is
> > > being loaded ,VM running low of memory.
> >
> > > My question is that, is there any tool to figure out which process is
> > > responsible for occupying memory so that we can look into the process
> > > for the exact reason.
> >
> > > Thanks,
> > > Amit
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
> >
> > --
> > Romain Guy
> > Android framework engineer
> > romain...@android.com
> >
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

2010-06-24 Thread Sebastian Roth
None of the tools I know work well with images and I'm not sure how to
improve that. One way might be to use adb shell tools like dumpsys and
compare the numbers over time, I heard. Not very convenient.

I'm checking the difference between PNG8 and PNG24 now. From my
understanding this could save some memory.

BR,
Seb

On Fri, Jun 18, 2010 at 5:00 AM, Nathan  wrote:

> Are any of those tools helpful with bitmaps?
>
> I've analyzed an HPRof where all the bitmaps are taking up32 bytes.
> that would be nice if it were true. I know that bitmaps are not on the
> regular heap, so the tools don't seem to find them.
>
> Since the bitmaps are marked as purgeable, they could be taking only
> 20K bytes, or as much as 256K bytes, so there is a wide range.
>
> Nathan
>
> On Jun 17, 8:35 am, Sebastian Roth  wrote:
> > Yup. We've been running in that case too many times.
> > Invest in a good tool like Yourkit, use HPROF Heap dumps to find the
> objects
> > with the sticky connects to JVM root and prepare to spend nights on
> trying
> > again and again..
> >
> > I recommend writing automated Unit-Tests for that as well. So that you
> can
> > call certain activities 100 times and see whether they retain in memory
> or
> > not. Very helpful for us.
> >
> > Also check basics like background pictures can be encoded as JPG instead
> of
> > PNG to save some memory...
> >
> > BR
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] java.lang.OutOfMemoryError: bitmap size exceeds VM budget

2010-06-17 Thread Sebastian Roth
Yup. We've been running in that case too many times.
Invest in a good tool like Yourkit, use HPROF Heap dumps to find the objects
with the sticky connects to JVM root and prepare to spend nights on trying
again and again..

I recommend writing automated Unit-Tests for that as well. So that you can
call certain activities 100 times and see whether they retain in memory or
not. Very helpful for us.

Also check basics like background pictures can be encoded as JPG instead of
PNG to save some memory...

BR

On Thu, Jun 17, 2010 at 3:33 PM, Romain Guy  wrote:

> When you get such an error it's because *your* process is running out
> of memory. Other processes have nothing to do with it. You are using
> too much memory in your process and blowing past the heap limit (16 MB
> or 24 MB depending on the device you're using.)
>
> On Thu, Jun 17, 2010 at 12:07 AM, Amit  wrote:
> > Hi
> >
> > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> > I am getting this message in my log. As I investigated and found out
> > while loading contact image this error comes.I checked  size of the
> > image file and it was normal so came to a conclusion that other
> > processes filling up the memory and hence at the time this image is
> > being loaded ,VM running low of memory.
> >
> > My question is that, is there any tool to figure out which process is
> > responsible for occupying memory so that we can look into the process
> > for the exact reason.
> >
> > Thanks,
> > Amit
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
> >
>
>
>
> --
> Romain Guy
> Android framework engineer
> romain...@android.com
>
> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: How to find memory leak?

2010-06-09 Thread Sebastian Roth
But when doing that, do not forget to convert the snapshots using *
hprof-conv*. I'm still searching for a automatic way.
We're using:
for i in *.andhprof; do hprof-conv $i `basename $i .andhprof`.new.hprof
;done

On Thu, May 20, 2010 at 8:19 PM, Mathias Lin  wrote:

> Yourkit, http://yourkit.com/overview/index.jsp, is another profiler
> tool that could be used.
>
> In sdk2.1, you can also do it on a non-rooted device - you can create
> a hprov from within the app and write it to sdcard.
>
> Debug.dumpHprofData("/sdcard/myapp.hprov");
>
> At least in v2.1, possible that this wasn't availabe in 1.x sdk.
>
>
>
> On May 20, 8:10 pm, pacoder  wrote:
> > I've been using Eclipse MAT (http://www.eclipse.org/mat/) to look at
> > heap dumps. My phone isn't rooted so I run my app in the emulator then
> > use adb to do a kill -10 which forces a heap dump. I then do an adb
> > pull to grab the file (your logcat will give you the name of the heap
> > dump output file when it runs). Then I use the android hprof-conv tool
> > to convert the heap dump to one that MAT can read. Then just open it
> > up in MAT and you can look around through the dump. It will also
> > suggest leak candidates to you, it's a nice tool. Also, you will need
> > to grant write permissions to the output directory in your emulator. I
> > just go do a chmod 777 /user/data.
> >
> > hth,
> >
> > Sean Overby
> >
> > On May 20, 6:27 am, Jiang  wrote:
> >
> >
> >
> > > When start Activity A, I found the memory usage of application is about
> 5MB,
> >
> > > Then start Activity B from A via startActivity. In Activity B, I
> created a thread, and  traverse file system
> in this thread, after traversing completed, call finish() and to return to
> Activity A. at this time, I found the memory usage of application is about
> 8MB (GC is forced before check memory usage).
> >
> > > How to find Where memory leaks?
> >
> > > By the way, I checked the memory usage with DDMS.
> >
> > > Thanks.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com
> > > For more options, visit this group athttp://
> 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group athttp://
> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en