After going through several posts I figured out I could send the intent with the following line of code (second line used for debugging):
int ret = system("am broadcast -a android.intent.action.MIKE_ACCESSED --user 0");
__android_log_print(ANDROID_LOG_DEBUG, "gxp18", "Shell command returned %i", ret);
Unfortunately, this returns always (No matter what is the command used in the system("...")):
Shell command returned 32512
Interestingly, I can successfully send the intent through adb using:
adb shell am broadcast -a android.intent.action.MIKE_ACCESSED
Notice! I am not using NDK. The piece of code I reported in the post is a modification of a portion of code in the Android Framework. In particular, it is part of one of the Android services. I am working with the AOSP and modifying part of the source code.