8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android で Runtime.getRuntime().exec(command) するときの注意点:クォーテーションは駄目

Posted at

Android アプリ内で直接コマンド実行するときに、コマンドラインにクォーテーション入ってるのは困るという話

:notes: ぜんてい

  • Android でアプリ内で直接コマンド実行したい
  • 引数が複雑でコンソールで使うときにクォーテーション入れるようなケース

:notes: れい

例えば hoge というコマンドがあって、-v "Hoge saves the world" と言う感じで引数を渡して実行するとき

String command = "hoge -v \"Hoge saves the world\"";
Runtime.getRuntime().exec(command);

というのは駄目で、Stringの配列で渡そう

Runtime.getRuntime().exec(new String[] {"hoge","-v","Hoge saves the world"});

■以上

:notes: あとがき

  • 絵文字を入れられるのはいいね :smile:
  • グロースハッカーは消えてください
8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?