Dialoge und der Screen Orientation Change

  • Antworten:1
Mac Systems
  • Forum-Beiträge: 1.727

27.04.2010, 12:33:37 via Website

Hallo,

so langsam aber sicher verliere ich die Geduld bei dieser doch recht simplen Sache. Sobald ich einen Dialog
erzeuge und diese mittels Activity#showDialog(NR) erzeuge bekomme ich eine Logcat Meldung in dieser Art
drücke ich im Emulator CTRL+F11 (Screen Orientation)

04-27 12:22:30.373: ERROR/WindowManager(719): Activity de.macsystems.TestActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@435d6428 that was originally added here

Hat jemand ein Bsp wie das umzusetzen ist ?

1protected void onCreate(final Bundle savedInstanceState)
2 {
3 ....
4
5 showDialog(UPDATE_SPOT_DIALOG);
6
7 }
8
9 private Dialog createUpdateProgressDialog()
10 {
11 if (Logging.isLoggingEnabled())
12 {
13 Log.d(LOG_TAG, "createUpdateProgressDialog");
14 }
15 final ProgressDialog dialog = new ProgressDialog(this);
16 dialog.setTitle("Updating");
17 dialog.setCancelable(true);
18 dialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener()
19 {
20 @Override
21 public void onClick(final DialogInterface _dialog, int _which)
22 {
23 System.out.println("Cancel clicked");
24 removeDialog(UPDATE_SPOT_DIALOG);
25 }
26 });
27// dialog.setOwnerActivity(this);
28 return dialog;
29 }
30
31 /*
32 * (non-Javadoc)
33 *
34 * @see android.app.Activity#onCreateDialog(int)
35 */
36 @Override
37 protected Dialog onCreateDialog(int _id)
38 {
39 if (Logging.isLoggingEnabled())
40 {
41 Log.d(LOG_TAG, "onCreateDialog :" + _id);
42 }
43 Dialog dialog;
44 switch (_id)
45 {
46 case (UPDATE_SPOT_DIALOG):
47 dialog = createUpdateProgressDialog();
48 break;
49 default:
50 dialog = null;
51 break;
52 }
53
54 return dialog;
55 }
Es gibt zwar zig Blogs/Posts dazu aber auch hier nur Vermutungen.
Auch habe Ich versuche das ganze mittels Dialog#setOwnerActivity(Context) zu lösen, auch hier kein Erfolg.
Das Problem tritt mit 1.5 sowie mit dem 2.01 SDK auf.

Danke,
Mac

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten
Mac Systems
  • Forum-Beiträge: 1.727

27.04.2010, 15:26:08 via Website

Lösung:
In der Methode onSaveInstanceState einfach den dialog mittels removeDialog(id) löschen und sich im Bundle merken das er gezeigt werden soll!

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten