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 functio开发者_运维百科n 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
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.
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
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);
精彩评论