Skip to content

Commit 2c5bf97

Browse files
grabboufacebook-github-bot
authored andcommitted
Feat/run android specify activity
Summary: Follow up to facebook#11049 that got overwritten. Differential Revision: D4390912 fbshipit-source-id: 0678ea2206a629093dda083816d40f538e627513
1 parent 52dea5d commit 2c5bf97

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

local-cli/runAndroid/runAndroid.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ function tryInstallAppOnDevice(args, device) {
150150
}
151151
}
152152

153-
function tryLaunchAppOnDevice(device, packageName, adbPath) {
153+
function tryLaunchAppOnDevice(device, packageName, adbPath, mainActivity) {
154154
try {
155-
const adbArgs = ['-s', device, 'shell', 'am', 'start', '-n', packageName + '/.MainActivity'];
155+
const adbArgs = ['-s', device, 'shell', 'am', 'start', '-n', packageName + '/.' + mainActivity];
156156
console.log(chalk.bold(
157157
`Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`
158158
));
@@ -167,7 +167,7 @@ function tryLaunchAppOnDevice(device, packageName, adbPath) {
167167
function installAndLaunchOnDevice(args, selectedDevice, packageName, adbPath) {
168168
tryRunAdbReverse(selectedDevice);
169169
tryInstallAppOnDevice(args, selectedDevice);
170-
tryLaunchAppOnDevice(selectedDevice, packageName, adbPath);
170+
tryLaunchAppOnDevice(selectedDevice, packageName, adbPath, args.mainActivity);
171171
}
172172

173173
function runOnAllDevices(args, cmd, packageName, adbPath){
@@ -215,7 +215,7 @@ function runOnAllDevices(args, cmd, packageName, adbPath){
215215
if (devices && devices.length > 0) {
216216
devices.forEach((device) => {
217217
tryRunAdbReverse(device);
218-
tryLaunchAppOnDevice(device, packageName, adbPath);
218+
tryLaunchAppOnDevice(device, packageName, adbPath, args.mainActivity);
219219
});
220220
} else {
221221
try {
@@ -286,6 +286,10 @@ module.exports = {
286286
description: '--flavor has been deprecated. Use --variant instead',
287287
}, {
288288
command: '--variant [string]',
289+
}, {
290+
command: '--main-activity [string]',
291+
description: 'Name of the activity to start',
292+
default: 'MainActivity',
289293
}, {
290294
command: '--deviceId [string]',
291295
description: 'builds your app and starts it on a specific device/simulator with the ' +

0 commit comments

Comments
 (0)