Friday, October 29, 2010

Running Android Native Code in your Android app





Just came over a post asking for Android's Logging Best Practices that took me to android log collector. Delving more deeper into log collector's code I got the below code to executes the specified command and its arguments in a separate native process.

All you need is just below code
String myStringArray[]= {"logcat","-d"};
Process process = Runtime.getRuntime().exec(myStringArray);
Setup the permissions for the required operation & you r done!Enjoy

But keep in mind Use Native Methods Judiciously & do check jon oberheide's Android Hax
And thanks to android-log-colllector team for the code.


Though the post describes a way of dropping a shell command from an app , check this for more ways to run shell commands from your app.
And also this  & I have heard MarketEnabler source offers a nice ShellInterface class.
So go get your app runnning!
See ya there at ./a.in

2 comments:

  1. Can I even run the command like "cp -r /xxx /xxx" in application?

    ReplyDelete
  2. What is a Casino in the USA? - Dr.MCD
    Casino 정읍 출장마사지 Types. Games 수원 출장샵 · 광명 출장샵 Video Poker · Live Casino · Craps · Keno · Blackjack. Video Poker 여수 출장마사지 · 강릉 출장샵 Live Casino · Keno · Video Slots.

    ReplyDelete