Skip to content

Commit d4dd85d

Browse files
Anthony NewnamGarmin Android technology group
authored andcommitted
Allow Am to start services
Change-Id: I31d066ae2c980cc293e55034446a63a0f42088ad
1 parent 69e398b commit d4dd85d

File tree

1 file changed

+15
-0
lines changed
  • cmds/am/src/com/android/commands/am

1 file changed

+15
-0
lines changed

cmds/am/src/com/android/commands/am/Am.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ private void run(String[] args) throws Exception {
8888

8989
if (op.equals("start")) {
9090
runStart();
91+
} else if (op.equals("start-service")) {
92+
runStartService();
9193
} else if (op.equals("instrument")) {
9294
runInstrument();
9395
} else if (op.equals("broadcast")) {
@@ -238,6 +240,19 @@ private void runStart() throws Exception {
238240
}
239241
}
240242

243+
private void runStartService() throws Exception {
244+
Intent intent = makeIntent();
245+
246+
if (intent != null) {
247+
System.out.println("Starting: " + intent);
248+
try {
249+
mAm.startService(null, intent, intent.getType());
250+
} catch (Exception e) {
251+
System.err.println("Error: " + e);
252+
}
253+
}
254+
}
255+
241256
private void sendBroadcast() throws Exception {
242257
Intent intent = makeIntent();
243258
IntentReceiver receiver = new IntentReceiver();

0 commit comments

Comments
 (0)