I want to execute a C program automatically during the start-up process. My C program named smackload.
I try to add service smackload /data/local/smackload in init.rc. It is no use.
I also add a command in one Action: exec /data/local/smackload
Could anyone give me some ideas? Thanks in advance!
You have to use NDK for that.For more details see this :-http://developer.android.com/tools/sdk/ndk/index.html
Related
I've successfully written a go mobile library and used it from an Android Java app.
I've also successfully called a c function from JNI. This one has the JNIEnv pointer.
I'd like to pass the context/JNIEnv from Java to Go.
Here's where it seems to get complicated:
Go Mobile does not seem to use JNIEnv at all.
LoadJNI.java does have a context object and claims to pass it to the Go side. But there it isn't visible.
I've been able to include jni.h using the "C" directive
I can transfer the JNIEnv from JNI/C or store it there as a global variable but that's an ugly kludge.
https://github.com/golang/go/issues/16876 talks about a proposal to do reverse binding but it's unclear what the status is.
https://godoc.org/golang.org/x/mobile/cmd/gobind also talks about it but the following code snippet
import "Java/java/lang/System"
t := System.CurrentTimeMillis()
returns
cannot find package "Java/java/lang/System" in any of:
/usr/local/go/src/Java/java/lang/System (from $GOROOT)
/Users/----/go/src/Java/java/lang/System (from $GOPATH)
In C I solved it with a compiler directive: #cgo CFLAGS: -I...
But I'm not sure how to do it for Java
In short, I'm now stuck and would appreciate help. Ideally, I'd just like to pass the object as a parameter, if possible. However, I'd settle for any reverse binding to call Java from Go.
I hate to answer my own question, but I'd hate someone to go through this as well too. I'll update this answer as I go along.
Basic Setup
Edit build.gradle and add GOPATH and GO to gobind (additions in bold):
gobind {
pkg = ".../reverse/reverse"
GOPATH = "/Users/johndoe/go"
GO = "/usr/local/go/bin"
}
How to develop
Start from the reverse example. Get it to compile and run.
Make one modification and recompile.
Missing gobind
It turns out the installation process neglected to build gobind. Run go install golang.org/x/mobile/cmd/gobind
I'm Stuck
Trying to modify the reverse project to do anything other than what it's already doing is failing. Even stuff like passing an object and calling toString will fail.
More to come...
I would like to write some C code , running in Android(linux) C program to set default route, ip -6 route add default dev wlan0.
Would appreciate if you have any idea, please let me know.
Best Regards
System/execl should work. But remember:
with execl you must put the full path to the executable. Also remember that you must put each parameter in its own string, and that the first parameter must be the binary program itself
you will need to run your program with root privileges to do what you want
I’m writing the error/failures of my steps to a file with this function:
def addToErrorFile(errorName)
open('error.txt', 'a') { |f| f.puts"#{errorName}"}
end
This function is located in a lot of places in my test flow.
To make it easier to read it in the end, I would like to add the step name (Then /I go to…) and also the scenario (Scenario: login to..).
Is there a way to copy those into the function?
You could put some code in your before and after scenario hooks that writes to the error log. That should break it up a bit and make it easier to read. Something like this.
Before do |scenario|
your_logging_method(scenario.name)
end
After do |scenario|
your_logging_method(scenario.name)
end
And there is an AfterStep hook too, though I haven't used it.
AfterStep do |step|
another_logging_method(step)
end
You may have to call some methods on the step variable to get it in a useful format.
Here's a link to the cucumber hooks documentatioon - https://github.com/cucumber/cucumber/wiki/Hooks
it wouldn't be better to use ruby (begin rescue ensure ) and put the code in there. You save your test session and you can progress your test to next steps, where you can put line of code to save name of next step to file
I learning android programming and in my first step I want to know what each function do
I discovered that all description about the function is found in activity.class.
IS my information right?
if it right I have a problem in activity.class in eclipse
and the error msg is the source attachment doesn't contain the source for the file Activity.class
what can i do ?
Here is all the information, that you need to know about activity http://developer.android.com/reference/android/app/Activity.html
I am using a system() call in a program , that is in c library. For 1st 9 calls it returns '0'(zero) after 10th call it returns 256. I do not know what does it mean. Please anybody help me. Following is the line of code
int returnValue= system("/system/bin/cat /dev/graphics/fb0 > /tmpdata/Screenshot/screenshot.bin");
According to this man page dealing with the general unix cat command, an error code >0 simply means an error occurred.
The following exit values shall be returned:
0
All input files were output successfully.
>0
An error occurred.
Your system() call is attempting to concatentate two files, so perhaps there is a space issue or maybe the source file does not exist.
You may also wish to take a look at some recent source code for Android cat (cat.c) which gives some indicatations of the kind of things that trigger errors within cat.