Skip to content

Commit

Permalink
Feat/run android specify activity
Browse files Browse the repository at this point in the history
Summary: Follow up to facebook#11049 that got overwritten.

Differential Revision: D4390912

fbshipit-source-id: 0678ea2206a629093dda083816d40f538e627513
  • Loading branch information
grabbou authored and facebook-github-bot committed Jan 9, 2017
1 parent 52dea5d commit 2c5bf97
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions local-cli/runAndroid/runAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ function tryInstallAppOnDevice(args, device) {
}
}

function tryLaunchAppOnDevice(device, packageName, adbPath) {
function tryLaunchAppOnDevice(device, packageName, adbPath, mainActivity) {
try {
const adbArgs = ['-s', device, 'shell', 'am', 'start', '-n', packageName + '/.MainActivity'];
const adbArgs = ['-s', device, 'shell', 'am', 'start', '-n', packageName + '/.' + mainActivity];
console.log(chalk.bold(
`Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`
));
Expand All @@ -167,7 +167,7 @@ function tryLaunchAppOnDevice(device, packageName, adbPath) {
function installAndLaunchOnDevice(args, selectedDevice, packageName, adbPath) {
tryRunAdbReverse(selectedDevice);
tryInstallAppOnDevice(args, selectedDevice);
tryLaunchAppOnDevice(selectedDevice, packageName, adbPath);
tryLaunchAppOnDevice(selectedDevice, packageName, adbPath, args.mainActivity);
}

function runOnAllDevices(args, cmd, packageName, adbPath){
Expand Down Expand Up @@ -215,7 +215,7 @@ function runOnAllDevices(args, cmd, packageName, adbPath){
if (devices && devices.length > 0) {
devices.forEach((device) => {
tryRunAdbReverse(device);
tryLaunchAppOnDevice(device, packageName, adbPath);
tryLaunchAppOnDevice(device, packageName, adbPath, args.mainActivity);
});
} else {
try {
Expand Down Expand Up @@ -286,6 +286,10 @@ module.exports = {
description: '--flavor has been deprecated. Use --variant instead',
}, {
command: '--variant [string]',
}, {
command: '--main-activity [string]',
description: 'Name of the activity to start',
default: 'MainActivity',
}, {
command: '--deviceId [string]',
description: 'builds your app and starts it on a specific device/simulator with the ' +
Expand Down

0 comments on commit 2c5bf97

Please sign in to comment.