top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to execute adb commands from android activity?

+3 votes
1,211 views
How to execute adb commands from android activity?
posted Nov 8, 2013 by Deepak Dasgupta

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
you cant try with abd shell commands for ex:-
Process proc = Runtime.getRuntime().exec(new String[]{ your adb commands });
proc.waitFor();

1 Answer

+2 votes

You should use Context.startInstrumentation, instead of adb. For example, from your Activity, run

startInstrumentation(new ComponentName("com.example.aatg.tc.test", "android.test.InstrumentationTestRunner"), null, null);

answer Jun 19, 2014 by Anuj Agrawal
how can i add -w flag and any other required flags while using this startInstrumentation() method.
Similar Questions
+3 votes

how can install apk through ADB in android device.

+3 votes

Hi, I have used the below sample code downloaded from a website and it is crashing.

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type
startActivity(sendIntent);

Let me know the possible solution.

...