Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7201] Android: UI.window - open and focus events fire more than once

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-01-16T15:37:51.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsAndroid
Labelsregression
ReporterPaul Dowsett
AssigneeMarshall Culpepper
Created2012-01-16T04:55:37.000+0000
Updated2017-03-22T21:27:01.000+0000

Description

Problem

Window open and focus events fire more than once (twice, in my tests). Note that open and focus is not currently fired at all for lightweight windows. See linked ticket for more info. Works as expected in 1.7.5, hence this is a regression.

Test case

var win = Ti.UI.createWindow({
  fullscreen:false,
  backgroundColor:'red'
});

win.open();

win.addEventListener('open', function() {
  Ti.API.info("------- Window event fired: open --------");
});

win.addEventListener('focus', function() {
  Ti.API.info("------- Window event fired: focus --------");
});

Logs

  914          AndroidRuntime  D  >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
  914          AndroidRuntime  D  CheckJNI is ON
  915           TiApplication  I  (main) [305,305] Titanium 1.8.0.1 (2011/12/22 13:09 fbdc96f)
  914          AndroidRuntime  D  --- registering native functions ---
  915               TiFastDev  D  (main) [311,616] Enabling Fastdev on port 60494
  915               TiFastDev  D  (main) [21,637] sent tokens successfully
  915               TiFastDev  D  (main) [2,639] Fastdev session handshake succesful.
  915           TiApplication  I  (main) [24,663] Titanium Javascript runtime: v8
  915           TiApplication  W  (main) [60,723] activity stack is emtpy, unable to get current activity
  915          TiRootActivity  I  (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[mParcelledData.dataSize=204]
  915           TiApplication  W  (main) [200,200] activity stack is emtpy, unable to get current activity
  915           TiApplication  W  (main) [0,200] activity stack is emtpy, unable to get current activity
  915           TiApplication  W  (main) [2,202] activity stack is emtpy, unable to get current activity
   60         ActivityManager  I  Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.appcelerator.testing10/.Testing10Activity }
  914          AndroidRuntime  D  Shutting down VM
  914          AndroidRuntime  I  NOTE: attach of thread 'Binder Thread #3' failed
  915           TiApplication  E  (KrollRuntimeThread) [1226,1428] APP PROXY: ti.modules.titanium.app.AppModule@44eda810
  915           TiAssetHelper  D  Fetching "app.js" with Fastdev...
   60         ActivityManager  I  Starting activity: Intent { cmp=com.appcelerator.testing10/org.appcelerator.titanium.TiActivity (has extras) }
  915          TiRootActivity  I  (main) [0,0] checkpoint, on root activity resume. activity = com.appcelerator.testing10.Testing10Activity@44f2d590
  915                   TiAPI  I  ------- Window event fired: open --------
  915                   TiAPI  I  ------- Window event fired: focus --------
  915                   TiAPI  I  ------- Window event fired: focus --------
   60     InputManagerService  W  Got RemoteException sending setActive(false) notification to pid 893 uid 10044
   60     NotificationService  W  Object died trying to hide notification android.app.ITransientNotification$Stub$Proxy@44f86088 in package com.appcelerator.testing10
   60         ActivityManager  W  setProcessForeground called on unknown pid: 893
   60         ActivityManager  I  Displayed activity com.appcelerator.testing10/.Testing10Activity: 56285 ms (total 3528 ms)
  915                   TiAPI  I  ------- Window event fired: open --------
   60         ActivityManager  I  Displayed activity com.appcelerator.testing10/org.appcelerator.titanium.TiActivity: 850 ms (total 850 ms)

Workaround

Use a boolean variable to determine whether the event has already been fired.

Comments

  1. Lee Morris 2017-03-22

    Closing as duplicate with regards to the information provided elsewhere in this ticket.

JSON Source