1

I have some main activity and clicking on a button it launches a custom dialog window. Within the dialog I have button "Send email" which calls an e-mail chooser (via simple method call) when user click on the button.

sendEmail();

And here is the sendEmail() method

public void sendEmail() {
    String email = "some.email@gmail.com";

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/plain");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{email});      
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Message");
    mContext.startActivity(Intent.createChooser(emailIntent, "Choose an email"));
}

But on my HTC Desire (2.2) sometimes the dialog starts blinking. Simply I cannot click on anything, I must quit an application OR I just rotate it in landscape and back and then flashing/blinking stops.

Where is the problem? Why is it blinking?

UPDATE: I tried to log "multiple calls" to sendEmail function or CreateDialog constructor but no, everything is called just one, after that I have this in my log... I could solve it to make another activity which will act like a dialog but I wanna know where is the problem here :/

Log

02-15 19:06:45.605 D/SurfaceFlinger(   92): Layer::setBuffers(this=0x9a9478), pid=12757, w=1, h=1
02-15 19:06:45.605 D/SurfaceFlinger(   92): Layer::setBuffers(this=0x9a9478), pid=12757, w=1, h=1
02-15 19:06:45.675 D/SurfaceFlinger(   92): Layer::requestBuffer(this=0x92b350), index=1, pid=12757, w=443, h=337 success
02-15 19:06:45.715 D/SurfaceFlinger(   92): Layer::requestBuffer(this=0x9a9478), index=0, pid=12757, w=480, h=762 success
02-15 19:06:45.755 I/UsageStats(   92): Unexpected resume of android while already resumed in android
02-15 19:06:45.815 D/SurfaceFlinger(   92): Layer::setBuffers(this=0x9a9478), pid=12757, w=1, h=1
02-15 19:06:45.815 D/SurfaceFlinger(   92): Layer::setBuffers(this=0x9a9478), pid=12757, w=1, h=1
02-15 19:06:45.895 D/SurfaceFlinger(   92): Layer::requestBuffer(this=0x9a9478), index=0, pid=12757, w=480, h=762 success
svenkapudija
  • 5,128
  • 14
  • 68
  • 96

3 Answers3

1

I have been messing with this same problem (chooser blinking after switching orientation). It finally turned out to be because I am using a custom locale on my application (as described here).

I replaced it by doing this on every onCreate of my activities & widgets (before calling super.onCreate()):

    Configuration config = getBaseContext().getResources().getConfiguration();

    String lang = "en"; //replace by your own method of getting user language

    locale = new Locale(lang);
    Locale.setDefault(locale);
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

Of course, you can pack that into a method so you just have to call it.

This way, choosers will stop blinking.

Community
  • 1
  • 1
Ereza
  • 1,434
  • 3
  • 15
  • 18
0

The blinking sounds like a recreation... have your tried to debug the application on the device? maybe put some log into the sendMail() so that you see how often it might be called

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
  • I added the log file. Maybe it can help. I'm trying to recreate it with "sendMail()" log but now it's working... Few times it's working then again not working and so on. Actually, now I realized I changed it a little - I have main activity and button - it launches custom dialog (in it's own class) with `ReportProblemDialog customDialog = new ReportProblemDialog(mContext); customDialog.show();` - class begins with `public class ReportProblemDialog extends Dialog {` and I'm passing in main activity context `public ReportProblemDialog(Context context) { super(context);`. – svenkapudija Feb 14 '11 at 23:21
  • As you can see in the log, your chooser is called multiple times. Try to debug the call and find out with the call trace what calls it. This is the only way I can think of to find the problem – WarrenFaith Feb 15 '11 at 09:40
  • Nope, everything is called only once (up there were my multiple calls trying to recreate the bug) :/ – svenkapudija Feb 15 '11 at 18:11
0

This solved the problem, where is actual problem I don't know.

change this

startActivity(Intent.createChooser(emailIntent,this.getString(R.string.someString)));

to this

startActivity(emailIntent);
svenkapudija
  • 5,128
  • 14
  • 68
  • 96