How to access Package Name from JNI/NDK?
来源:互联网 发布:美国 网络战 话语权 编辑:程序博客网 时间:2024/05/16 00:39
#include <jni.h>#include <string>#include <unistd.h>#include <sys/types.h>#include <sys/file.h>#include <dirent.h>#include <stdlib.h>#include <ctype.h>#include <fcntl.h>extern "C"jstringJava_xl_com_myapplication_MainActivity_stringFromJNI( JNIEnv *env, jobject /* this */) { std::string hello = "Hello from C++"; //getuid char args[4096], path[4096]; pid_t pid = getpid(); snprintf(path, sizeof(path), "/proc/%u/cmdline", pid); int fd = open(path, O_RDONLY); if (fd < 0) { return NULL; } ssize_t len = read(fd, args, sizeof(args)); close(fd); if (len < 0 || len == sizeof(args)) { return NULL; } printf("The package name is %s\n", args); hello = args; return env->NewStringUTF(hello.c_str());}
http://man7.org/linux/man-pages/man2/getpid.2.html
https://android.googlesource.com/platform/system/core.git/+/donut-release/toolbox/ps.c
0 0
- How to access Package Name from JNI/NDK?
- How to delete PACKAGE from HANA studio
- How to access Excel from Perl
- how to know the package name of android apk?
- How to access other computer using different name/password
- NDK/JNI Develop Guide (4) How to use Array
- [cernRoot]How to get tree name from root file
- How to solve the emulator -5554 disconnected! Cancelling 'package name.class name activity launch'!
- How to Call Java functions from C Using JNI
- How to Call Java Functions from C Using JNI
- How to remove access point from saved list
- How to access Dropbox from the command line in Linux
- How to access Tomcat 8 admin gui from different host?
- Package supports: Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: ./jni/Android.mk
- How to migrate DTS package from Server A to Server B
- How to list the latest installed RPM package name (文档 ID 1553104.1)
- Seems you're trying to access 'ReactNative.Component' from the 'react-native' package. Perhaps you m
- Install an RPM Package on Ubuntu Linux(from how to geek)
- Android Studio使用
- CQL(Cassandra Query Language)JSON支持
- ldd-print shared object dependecies
- 【Linux】文件的权限管理
- char * const *(*next)();
- How to access Package Name from JNI/NDK?
- 控制台光标(二):设置光标位置
- js获取html标签
- 使用Angular2及WebApi开发SPA类型的企业应用 - Part 3 项目结构
- 【Android】TextView中不同大小字体如何上下垂直居中?
- Android 仿iOS 开关SwitchButton
- CListCtrl高亮显示一行
- js闭包-个人浅理解
- HDU 3395 Special Fish(KM算法)