Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8889] Android: android:back event does not get fired from activity indicator

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-06-18T18:16:45.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsapi
ReporterAllen Yeung
AssigneeJosh Roesslein
Created2012-04-25T15:06:57.000+0000
Updated2017-03-24T18:10:54.000+0000

Description

Repro steps: 1. Run the code below 2. hit back while the activity indicator is running Expected result: You should see 'back!!!!!!!' in the logs Actual result: The event is never fired. Note, I tried adding the listener to the win1, win2, and activityIndicator with the same results.
Ti.UI.backgroundColor = 'white';

var win1 = Ti.UI.createWindow({
  backgroundColor: 'blue'
});

var win2 = Ti.UI.createWindow({
  backgroundColor: 'yellow',
  fullscreen: true
});

var activityIndicator = Ti.UI.createActivityIndicator({
  color: 'green',
  font: {fontFamily:'Helvetica Neue', fontSize:26, fontWeight:'bold'},
  message: 'Loading...',
  style:Ti.UI.iPhone.ActivityIndicatorStyle.DARK,
  top:10,
  left:10,
  height:'auto',
  width:'auto'
});

// On iOS, the activity indicator must be added to a window or view for it to appear
if (Ti.Platform.name === 'iPhone OS'){
  win2.add(activityIndicator);
}

// eventListeners must always be loaded before the event is likely to fire
// hence, the open() method must be positioned before the window is opened
win2.addEventListener('open', function (e) {
  activityIndicator.show();
  // do some work that takes 6 seconds
  // ie. replace the following setTimeout block with your code
  setTimeout(function(){
    win2.close();
    activityIndicator.hide();
  }, 6000);
});

activityIndicator.addEventListener('android:back', function(){
	Ti.API.info('back!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
});

win1.open();
win2.open();

Comments

  1. Josh Roesslein 2012-04-30

    Proposed solution: Expose a "cancel" event on the ActivityIndicator proxy. For Android this will be fired when the back button is pressed. Indicator dialog will be hidden before the event is fired. This is only enabled when the property "cancelable" is true (false by default). Bonus: Android also supports cancelling via a touch outside the dialog. Could expose this as another property (ex: cancelOnTouch). Example:
       var indicator = Ti.UI.createActivityIndicator({
         message: "Processing...",
         cancelable: true
       });
       
       indicator.addEventListener('cancel', function() {
         // abort the processing here.
       });
       
    Would this satisfy your use case and solve the issue?
  2. Josh Roesslein 2012-04-30

    Looks like this will only be an Android API since iOS and Mobile Web don't use modal dialogs for the activity indicator.
  3. Vishal Duggal 2012-05-04

    Resolved by PR #2118
  4. Eric Cheng 2012-05-09

    The customer is on 1.8.2. Can the fix be backported to support 1.8.2. Customer delivery date is 5/11.
  5. Neeraj Gupta 2012-05-09

    @Eric - We are not porting new features back to older releases. This issue was resolved by implementing a new feature so we cannot put it in 1.8.X branch.
  6. Eric Merriman 2012-06-18

    This still occurs with SDK 2.1.0.v20120618102300 on a Droid running 2.2.3.
  7. Josh Roesslein 2012-06-18

  8. Josh Roesslein 2012-06-18

    We won't fix the unsupported/undocumented behavior this test case describes here. Instead we implemented the API/feature in TIMOB-8954 to satisfy the customer's use case.
  9. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source