Don't use non-SDK APIs.

On Sat, Feb 21, 2009 at 8:12 PM, surferdude <[email protected]> wrote:
>
> Hello,
>
> I'm trying to write my first android application which executes
> commands I feed to it on the comandline. I looked through the public
> git repository and found android.os.exec which should meet my needs
> fine, however I noticed that it isn't part of the SDK. When I try to
> add the class to my project and call it via createsubprocess(), it
> compiles fine but i get a force close as soon as it tries to run on
> the emulator or my device. According to the ddms logs, its getting
> stuck at an unsatisfied link error. Below are the three files in my
> project... if anyone could help me out, it would be much appreciated
>
> -------------------
>
> testapp.java:
>
> -------------------
>
> package com.android.testapp;
>
> import android.app.Activity;
> import android.os.Bundle;
> import com.android.testapp.exec;
>
> public class testapp extends Activity {
>    /** Called when the activity is first created. */
>    @Override
>    public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>        setContentView(R.layout.main);
>
>        exec.createSubprocess("ls",null,null);
>    }
>
>
> }
>
> -------------------
>
> exec.java
> -------------------
> package com.android.testapp;
>
>
>
> import java.io.FileDescriptor;
>
> /**
>  * @hide
>  * Tools for executing commands.  Not for public consumption.
>  */
>
> public class exec
> {
>    /**
>     * @param cmd The command to execute
>     * @param arg0 The first argument to the command, may be null
>     * @param arg1 the second argument to the command, may be null
>     * @return the file descriptor of the started process.
>     *
>     */
>    public static FileDescriptor createSubprocess(
>        String cmd, String arg0, String arg1) {
>        return createSubprocess(cmd, arg0, arg1, null);
>    }
>
>    /**
>     * @param cmd The command to execute
>     * @param arg0 The first argument to the command, may be null
>     * @param arg1 the second argument to the command, may be null
>     * @param processId A one-element array to which the process ID of
> the
>     * started process will be written.
>     * @return the file descriptor of the started process.
>     *
>     */
>     public static native FileDescriptor createSubprocess(
>        String cmd, String arg0, String arg1, int[] processId);
>
>     public static native void setPtyWindowSize(FileDescriptor fd,
>       int row, int col, int xpixel, int ypixel);
>    /**
>     * Causes the calling thread to wait for the process associated
> with the
>     * receiver to finish executing.
>     *
>     * @return The exit value of the Process being waited on
>     *
>     */
>    public static native int waitFor(int processId);
> }
>
> ---------------
>
> androidmanifest.xml
> ---------------
>
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android";
>      package="com.android.testapp"
>      android:versionCode="1"
>      android:versionName="1.0.0">
>    <application android:icon="@drawable/icon" android:label="@string/
> app_name">
>        <activity android:name="testapp"
>                  android:label="@string/app_name">
>            <intent-filter>
>                <action android:name="android.intent.action.MAIN" />
>                <category
> android:name="android.intent.category.LAUNCHER" />
>            </intent-filter>
>        </activity>
>    </application>
> </manifest>
>
>
>
>
> >
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to