Issue
Android can use adb shell service call SERVICE
to communicate with .aidl file, pass arguments and get return value. However, it belongs Android source code. Is it possible I can do the same thing after install non-system app which is written by myself?
For example, I write an app which its package name is com.test.aidl
and there is a function inside.
fun add(x: Int, y: Int): Int {
return x +y
}
Can I use adb command, such as adb shell service call com.test.aidl add i32 1 i32 2
and get value 3
on command prompt?
Solution
I've resolved this using instrument.
ADB command
adb shell am insrument -e <NAME> <VALUE> <package/runner>
Android
public class Test extends android.test.InstrumentationTestRunner{
@Override
public void onCreate(Bundle bundle) {
super.onCreate(arguments);
value = (String) bundle.get("name");
}
Then use sendStatus api to print on CMD.
Answered By - LaoDa581
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.