Execute setprop command from application

by Giorgio M. » Wed, 04 Mar 2009 02:01:04 GMT


Sponsored Links
 I have to execute the shell command

setprop net.dns1 xxx.xxx.xxx.xxx

from an android activity but i can't find a working way to do it.

How can i execute this command from the application?

thanks

-- 
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com


--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Intent.putExtra (String name, String[] value) caching old value

Try using setData() to store your message instead of extras: that
forces the Intent to be seen as a new one. Or you can keep using
extras and
create some other unique token every time for setData().

Lee

p.s. also see the flags you can use at the end of the getService call
(read
the PendingIntent docs). There's something like
'FLAG_REPLACE_CURRENT'.




--~--~---------~--~----~------------~-------~--~----~

2. Can't i call a service function in activity's onStart/onCreate?

My activity bind a service.  I want to call the service's function in
actitity's onStart/onCreate function, but it doesn't work.
The service started suncess but the connection is null.

When I just call the service's function in other function (onClick for
example),  it works well.

thanks for help.

here is my code:

public class AidlTest extends Activity
{
    private static final String TAG = "AidlTest";
    IAidlService mService;

    private OnClickListener mCorkyListener = new OnClickListener() {
        public void onClick(View v) {
            test();
        }
    };

    private ServiceConnection mConnection = new ServiceConnection() {

        public void onServiceConnected(ComponentName className,  IBinder
service) {
            mService = IAidlService.Stub.asInterface(service);
        }
        public void onServiceDisconnected(ComponentName className) {

            mService = null;
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        TextView v = new TextView(this);
        setContentView(v);
        v.setOnClickListener(mCorkyListener);
        Log.v(TAG, IAidlService.class.getName().toString());
        Intent intent = new Intent(IAidlService.class.getName());
        bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    }

    @Override
    public void onStart(){
        super.onStart();
        Log.d(TAG, "onStart");
        test();
        }
    }

    public void test(){
        if (mService == null){
            Log.d(TAG, "mService is NULL");
        }
        try {
            mService.test();
        }catch (RemoteException e){
            Log.d(TAG, e.toString());
        }
    }
}



Bear

--~--~---------~--~----~------------~-------~--~----~

3. Custom View using XML layout & EditTexts: SavedState conflict

4. Can i fetch the latest image from gallery taken from camera ?

5. ListView Urgent Help Req :)

6. Help with UI XML

7. trouble with programmatically adding mock location data