Skip to content

Commit

Permalink
Run application once installed to Android device.
Browse files Browse the repository at this point in the history
[TIMOB-11325]
  • Loading branch information
Joshua Roesslein committed Oct 9, 2012
1 parent b0ee6bf commit 651d4b7
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion android/cli/commands/_build.js
Expand Up @@ -408,14 +408,46 @@ function build(logger, config, cli, finished) {
cli.argv['android-sdk'],
'-e'
], options);
} else if (cli.argv['target'] == 'device') {
// Since installing on device does not run
// the application we must send the "intent" ourselves.
// We will launch the MAIN activity for the application.
logger.info(__('Launching appliation on device.'));
spawn('adb', [
'shell', 'am', 'start',
'-a', 'android.intent.action.MAIN',
'-c', 'android.intent.category.LAUNCHER',
'-n', tiapp.id + '/.' + appnameToClassname(tiapp.name) + 'Activity',
'-f', '0x10200000'
], options).on('exit', function (code) {
if (code) {
err = __('Failed to launch application.');
}
finished && finished.call(this, err);
});
return; // Do not finish until the app is running.
}
finished && finished.call(this, err);
}.bind(this));
}.bind(this));
}

// Converts an application name to a Java classname.
function appnameToClassname(appname) {
var classname = appname.split(/[^A-Za-z0-9_]/).map(function(word) {
return appc.string.capitalize(word);
}).join('');

// Classnames cannot begin with a number.
if (classname.match(/^[0-9]/) !== null) {
classname = '_' + classname;
}

return classname;
}

build.prototype = {

//

};
};

0 comments on commit 651d4b7

Please sign in to comment.