Android :: Native Code Called Successfully But Not Executed Properly
Sep 10, 2009In Android , Native code is written as follows.
JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env, jobject obj) {
printf("THIS IS TEST");
}
In Android , Native code is written as follows.
JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env, jobject obj) {
printf("THIS IS TEST");
}
I have an AIDL service that is intended to be used by both out-of- process remote users and in-process local users. As a result, my common interface methods will either be invoked on the UI thread or in a binder background thread. The logic between the two is not the same. How do I distinguish between these two cases?
View 4 Replies View RelatedI am developing a app using android C2DM. sqlite3 is my back-end. Everything is just working fine but am struck with an performance issue regarding sqlite3. so my question is 'can i place the database code somewhere where it will be executed only once i.e The dvm(dalvik vertiual machine) should execute the code pertaining to the db only once; during the successive run the dvm should not go thru the (db)code because the db had been created.
More specifically, my app send msg to all the phones which has my app. so when an app at the client end receives a msg, the dvm should not execute this code : SQLiteDatabase db;
//use tat ref to open or create a table
db = openOrCreateDatabase( "/data/data/de.vogella.android.c2dm.simpleclient/app_database/file__0/0000000000000001.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
try
{
[code]....
Because everytime a msg comes this code ll be executed.
I am invoking the default SMS activity by using the following code-
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:")); intent.putExtra("sms_body", "SMSText"); startActivityForResult(intent, 11); //Here 11 is my request code
The SMS activity gets opened in emulator (5554), i type the number 5556 (device number of my second emulator) and click on "Send"
The SMS is received in second emulator(5556) successfully. I click back on 5554 (my SMS generating emulator )and come back to my application. I notice that the onActivityResult method is getting called successfully as desired.
When i check for the result code i get it as RESULT_CANCELED ( 0 ) instead of RESULT_OK (-1). The data is also coming as null.
First off let me say this...best phone that has EVER touched my hands.Now that being said, does the native gmail app NOT have the ability to properly view html emails? I get emails from multi sources (I.e. Costco, Sprint, etc) that get loomed in and I have to pan around the email. I tried pinching or double rapping but o no avail. Anyone have a decent solution for said problem?
View 1 Replies View RelatedI have a library written in C which implements some complicated algorithm over two databases and as a result produce new one. I am trying to import it in android using android-ndk. What is the correct wat to use sqlite in you native libraries, i was able to build the sqlite manually using the ndk but when i use it gives some strange errors when trying to fetch rows from db which is on phone storate - after i fetch some data i got SQL:database not opened. how can use sqlite in native code on android.
View 2 Replies View RelatedWe know that it's very convenient to use TraceView in Android java code to check the runtime of different chunks of code. Now I develop my app with NDK and I want to check the runtime of some native functions, but I found nothing in TraceView guide if it's possible to use this tool. Because I noticed that one of my native methods spent too much time and I want to dig out the more detailed root cause. Is there anybody know if we can use TraceView in native code?
View 2 Replies View RelatedI am planning to write a video player application and I am planning to use the gstreamer on the native side. I am trying to use the SurfaceFlinger for the rendering part. For this I have written a test program to experiment on the rendering part. I am using the surface flinger wrapper from the project
http://gitorious.org/rowboat/external-gst-plugins-android
But the following ERROR occurs when we try to run the .apk.
CODE:.......
The I changed the permission for "android.permission.ACCESS_SURFACE_FLINGER" in frameworks/base/core/ res/AndroidManifest.xml to "dangerous" and recompiled. But got the same error.
Then I commented out the "checkCallingPermission" method in IServiceManager.cpp and recompiled. Then also i got the same error.
I'm writing an app for Android OS, and I need to store some time values in the SQLite DB. I have been using android.text.format.Time to store the time values in the app, and then inserting the values as millis into the DB as REAL values. On the SDK emulator, everything works perfectly. On the sole phone I've had the opportunity to test my app (so far), my duration code doesn't work as expected. Some relevant code:
private static final String DATABASE_CREATE =
"create table " + DATABASE_TABLE + " ("
+ KEY_ROWID + " integer primary key autoincrement, "
+ KEY_START + " REAL, "
+ KEY_STOP + " REAL, "
+ KEY_DUR + " REAL );";
private SQLiteDatabase mDb;
ContentValues timerValues = new ContentValues();
timerValues.put(KEY_START, stime.toMillis(false));
timerValues.put(KEY_STOP, etime.toMillis(false));
timerValues.put(KEY_DURATION, stime.toMillis(false)-etime.toMillis(false));
int result = mDb.insert(DATABASE_TABLE, null, timerValues);
I pull this data from two separate functions with slightly different bits of code, both using Time.set(long millis), both giving incorrect results: The start and stop values come back correct, but the duration comes out 17 hours too large. Am I missing something about calculating durations or does this just seem like there's something "special" about this particular droid? I'll have another droid to test on Monday, but any ideas are appreciated.
Is this possible to access a sensor data form native code without using Java at all? I need to access to the sensor as fast as possible, but it seems like the "DELAY_FASTEST" parameter when registering an event change is not fast enough.
View 3 Replies View RelatedI created one android application it is using one native method. I created shared library using ndk tools.My jni function is having some problems i want to debug it. How to debug it in eclipse tool
View 2 Replies View RelatedI set out to use SkCanvas and other native SKIA classes but I could not find any sample code. After a week's of search and diving deep into Android source, I got it working. Below in my blog, I have detailed, how to use SimpleJNI native sample, to get native canvas going. If you find it useful or I did something wrong let me know http://matthiyosi.blogspot.com/2009/10/using-skia-in-android-native-c...
View 6 Replies View RelatedI have some piece of code which uses JNI. I can debug code wrote in Java directly in Eclipse (using ADT). I even have a script, which help me debug native code with gdb. However this is not very comfortable way for doing this.Is it possible to configure Eclipse to use gdb (I guess gdbserver) for debbuging android native applications? Do you know where I could find any description of this?
View 1 Replies View RelatedWe want to migrate a huge complex native program to Android system ,running it as a background service accepting command sent from Java Program using JNI along with IPC. However, the Android NDK state following words:
Please note that the NDK does not enable you to develop native-only applications. Android's primary runtime remains the Dalvik virtual machine.
Does that mean we have no way to run an standalone native-only application on Android as a background service? The native code can only exist in the form of library that will be loaded to the virtual machine through JNI?
I am creating an Android application which uses the JMF (SIP, RTP, JAIN). So i downloaded the JMF source code for some adhoc change to my application.The basic questions 1. How will it behave the "native files - C/C++/header" in JMF source files(downloaded)? because android is based on java right now. 2. Is there any complete different way to porting/doing the SIP, RTP working in android?Is there any link from sun.com(this) site for JMF source code?Any suggestion and comment about this?
View 3 Replies View RelatedHow I can add headers to my native c file.
So here's the details.
I was able to setup my android project to call a native function from a .so file. And actually I need to add box2d to my project, but I when I include the header files, it won't make. So basically my problem is how do I tell the make file to include a whole folder with header and cpp files.
I tried adding the path directly to the include statement just for the sake of testing it. The error goes away, but new errors come out.
Is it possible to broadcast an Intent from native code? If so, is there documentation and/or sample code pertaining to the relevant APIs?
View 1 Replies View RelatedI am trying out an example of OpenCV from http://github.com/billmccord/OpenCV-Android and am stuck at the point where it is mentioned "Before attempting to run the VideoEmulator application, you must first copy this XML file into the emulator in the following location: /data/data/org.siprop.opencv/files/haarcascade_frontalface_alt.xml " Where in my eclipse workspace do I need to place this haar xml file to be copied to the location /data/data/org.siprop.opencv/files/ of the emulator?
View 1 Replies View RelatedWhen I debug android app, if I work with Java, I can use Log.d("TAG", "xxxx", new Throwable()) to print backtrace of Java code. This is really handy for me to find bugs. But when I work with native library (e.g. libwebcore.so), there seems no way to print backtrace in runtime. The only way to debug native code is use gdbserver.
I have a question: Is there any way to print backtrace in C/C++?
Try to select (or update) from custom databases (for example mmssms.db) but on init I see " Unable to open the database file". Try send permissions in manifest <uses-permission android:name="android.permission.WRITE_SMS"/> <uses-permission android:name="android.permission.READ_SMS"/> but this doesn't help.
View 2 Replies View RelatedI've a very simple / minimal code application.
I'm drawing some lines on screen with my finger.
At some point, app closes itself / exists automatically.
No exception is thrown.
CODE:......................
I am trying to figure out what is the best way to debug a mix of Java and native code? Please notice, that I am NOT trying to develop a native app. The app will be written entirely in Java, using Android SDK. However, I noticed that some pieces of the SDK use native methods (e.g. AssetManager, WebKit, etc). I wonder which tools Google developers use if/when they need to debug a mix of Java and C/C++ code? Eclipse/gdb or there are commercial tools which make the debugging experience less painful?
View 2 Replies View RelatedI wrote an iPhone app some time ago that creates sound programatically. It uses an AudioQueue to generate sound. With the AudioQueue, I can register for a callback whenever the system needs sound, and respond by filling a buffer with raw audio data. The buffers are small, so the sound can respond to user inputs with reasonably low latency.
I'd like to do a similar app on Android, but I'm not sure how. The MediaPlayer and SoundPool classes seems to be for playing canned media from files, which is not what I need. The JetPlayer appears to be some sort of MIDI playback engine. Is there an equivalent to AudioQueue in the Android Java API? Do I have to use native code to accomplish what I want?
I started my emulator with ./emulator -trace profile -avd emulator_15. I then tracked down the trace files to ~/.android/avd/rodgers_emulator_15.avd/traces/profile, where there are six files: qtrace.bb, qtrace.exc, qtrace.insn, qtrace.method, qtrace.pid, qtrace.static. I can't figure out what to do with these files. I've tried both dmtracedump and traceview on all of the files, but none seem to generate any output I can do anything with.
How can I view the proportion of time taken by native method calls on Android?
I'm try to make a dial in native code, could i make a dial with RIL through socket or IPC communication?or push AT command directly to GSM Modem.
View 2 Replies View RelatedI am using below code for scheduling a task in android but its not giving any results.
int delay = 5000; // delay for 5 sec.
int period = 1000; // repeat every sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
Toast.makeText(getApplicationContext(),"RUN!",Toast.LENGTH_SHORT).show();
}
}, delay, period);
Currently I am trying to compile native code for Android. The code is from the OpenCV port for Android. I pasted all the code correctly in my project and edited my make files accordingly. When I set android:debuggable to false everything works fine and I get my native library. When I try while android:debuggable is set to true I get an error.
Here is a part of the log:
CODE:....................
From what I have found on the internet this is caused by the optimization level of the compilation. As long as the code isn't compiled so that is is debuggable afterwards everything should be fine.
Now apparently it is possible to avoid this by setting APP-OPTIM := release in the Application.mk or adding -O2 to LOCAL_CFLAGS. I have tried both and still I get this error.
Right now I don't really care that much about debugging my native code, but I would like to have basic debugging enabled. And I don't want to keep switching android:debuggable in my manifest every time I want to compile. I'm not even sure if it is okay at all if I just set android:debuggable to false pre compiling and to true post compiling, but I am sure I will forget it every second run.
The following is the log from native code.
CODE:.................
I am new to android development and have been playing around with the tutorials offered at developer.android.com.I don't have a problem with projects I create from scratch, but when I start a project from the android sample code provided at android.com or from any other android project, I can never seem to get the bugs out to even run the thing.For example, when loading up the NotePad sample in the android-7 package of samples.would like a general solution, something more global bc this is occurring whenever I pull in anyone's source code from outside.kind of frustrated because I feel that I am spending too much time working out these kinks and not being able to study other people's code against how it performs in the emulator.
View 3 Replies View RelatedI've synced my android repository just after android sdk 1.6 announced, but found some problem to install my apps with native code (so built by NDK 1.5_r1) then.
I tried to build NDK with the latest source code, bu unfortunately, faile again :( .
So is there any way to get particular version of android source code? for example the android-1.5r3 tag. Would be great if some command like "svn switch /foo/bar/1.5r3" is available.