Android NDK __android_log_print function and LogCat

前端 未结 1 672
梦如初夏
梦如初夏 2021-02-19 04:02

I have a function like

__android_log_print(ANDROID_LOG_INFO, \"HelloNDK!\");

on my C code

I wouldn\'t find that output on my LogCat. W

1条回答
  •  滥情空心
    2021-02-19 04:53

    You don't find output because you have misused the function. The function has the prototype:

    int __android_log_print(int prio, const char *tag,  const char *fmt, ...);
    

    So you must supply a "tag" as well as the format.

    For example

    __android_log_print(ANDROID_LOG_INFO, "MyTag", "The value is %d", some_variable);
    

    Once you use the function properly, you can use any filtering method (or none at all - such as you'd get from the adb logcat command without further arguments) just as with java code.

    0 讨论(0)
提交回复
热议问题