adb devices连接设备

Android数据线要用好一点的线,有的劣质线只能充电,不能传输数据。

手机上找到系统版本,触摸5下打开开发者选项,打开usb调试,手机上确认连接fingerprint

安装ndk support插件

* MainActivity.java

package com.example.mysdkdemo;import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;public class MainActivity extends AppCompatActivity {static {System.loadLibrary("mysdkdemo");}public native String getStringFromNative();@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}@Overridepublic boolean onTouchEvent(MotionEvent event) {boolean shouldClose = super.onTouchEvent(event);System.out.printf("(%f,%f), keycode=%d", event.getRawX(), event.getRawY(), event.getActionIndex());System.out.println(this.getStringFromNative());return shouldClose;}
}

*mysdkdemo.cpp

#include <jni.h>
#include <string>extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_mysdkdemo_MainActivity_getStringFromNative(JNIEnv *env, jobject thiz) {std::string hello = "Hello from C++";return env->NewStringUTF(hello.c_str());
}

运行,手机上触摸屏幕

* CMakeList.txt


# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html# Sets the minimum version of CMake required to build the native library.cmake_minimum_required(VERSION 3.22.1)# Declares and names the project.project("mysdkdemo")# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.add_library( # Sets the name of the library.mysdkdemo# Sets the library as a shared library.SHARED# Provides a relative path to your source file(s).mysdkdemo.cpp )# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.find_library( # Sets the name of the path variable.log-lib# Specifies the name of the NDK library that# you want CMake to locate.log )# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.target_link_libraries( # Specifies the target library.mysdkdemo# Links the target library to the log library# included in the NDK.${log-lib} )

* sim.bat

for /l %%i in (1,1,1048576) do (echo %%iadb shell input tap 269 707timeout /T 2 /NOBREAKadb shell input tap 584 2099timeout /T 2 /NOBREAKadb shell input keyevent 4timeout /T 2 /NOBREAK
)

android native方法调用相关推荐

  1. JAVA中native方法调用C语言实现学习

    在java虚拟机规范的内存管理划分中,对于虚拟机内存空间划分中专门划了一块内存叫做"本地方法栈(Native Method Stack)".本地方法栈是为了java专门用来调用na ...

  2. android中方法调用super(..)的相关知识

    java中的多态有重写 方法被子类重写后 父类的原方法就会被隐藏 当你又需要调用父类所定义的原方法  这个时候就可以用super来调用 super调用指向了父类,在一些调用里可以很巧妙的利用,比如监听 ...

  3. android 跟踪方法调用,如何连续跟踪Android手机的位置?

    我需要编写一个应用程序,每隔5分钟确定一次移动电话的当前位置(使用所有免费的可用位置提供商)并将其发送到服务器. 如果某个位置提供程序在应用程序启动时不起作用,但稍后可用,则应用程序也应处理其位置数据 ...

  4. Android 打印方法调用堆栈

    RuntimeException here = new RuntimeException("here");here.fillInStackTrace();Log.w("y ...

  5. Java JNI实现调用自定义Native 方法

    JNI是Java Native Interface的缩写,通过使用 Java本地接口书写程序,可以确保代码在不同的平台上方便移植.从Java1.1开始,JNI标准成为java平台的一部分,它允许Jav ...

  6. android native.js,Android Native与JS通信互调

    写在最前: 看Android最新技术总结,关注公众号: 最近因为App与H5交互逻辑太乱,所以抽空梳理了下:对目前App与H5的各种交互通信做个总结,自取适合自己的交互方式. 一.H5调用原生的nat ...

  7. android transact,Android Native层Binder.transact()函数调用 Binder.onTransact() 函数失败分析...

    Q:Android Native层Binder.transact()函数调用 Binder.onTransact() 函数失败? 在Android Native层调用Camera.h中的api实现一个 ...

  8. 【学习Android NDK开发】Java通过JNI调用native方法

    参考:Android NDK,sample/hello-jni示例项目 系统环境:Ubuntu 12.04 LTS 32-bit 1.准备工作 打开Eclipse,新建Android项目: Appli ...

  9. 【Android 内存优化】Android 原生 API 图片压缩原理 ( 图片质量压缩方法 | 查找 Java 源码中的 native 方法对应的 C++ 源码 )

    文章目录 一. 图片质量压缩方法 二. 查找对应的 Native 方法源码 三. 分析 Bitmap.cpp 中动态注册 Native 方法 在博客 [Android 内存优化]图片文件压缩 ( An ...

最新文章

  1. 腾讯优图10篇AAAI论文解析,涉及数学速算批改、视频识别和语义分割 | 附下载...
  2. Extjs4.2——Panel
  3. C# 调用C++写的dll的实现方法
  4. P1313 计算系数(组合数)
  5. python 虚拟环境 django.db 报错_jumpserver一体化安装
  6. [LeetCode] 3. Longest Substring Without Repeating Characters 题解
  7. socket.io跨域踩坑
  8. java 持续集成工具_Jenkins-Jenkins(持续集成工具)下载 v2.249.2官方版--pc6下载站
  9. 服务器端渲染为什么会比较快,原理是什么?
  10. 【UVA10562】Undraw the Trees(括号表示法输出树+fegts读取)
  11. 微信公众号的html5界面用什么软件,微信公众号编辑排版用什么软件(推荐这4款编辑器)...
  12. 五年了,我在 CSDN 的两个一百万。
  13. Duality对偶学习笔记(第一课时)
  14. Java数据结构和算法-图
  15. C#表达式目录树系列之5 –动态创建查询表达式
  16. 平方米用计算机怎么打,平方厘米用电脑怎么打
  17. 重启数据库服务器后数据库无法连接的解决方法
  18. VB6.0中关于setfocus用法
  19. 可穿戴的“舌头鼠标”,催生“黏腻”人机交互的新想象?
  20. 宝塔搭建TY博客附好看模板

热门文章

  1. 【Iass Saas Paas】
  2. 2021.1.22平安科技面经--算法工程师实习生
  3. 台式计算机激光头,制作用4节电池+光驱激光头纯手工改造激光枪
  4. Elasticsearch数据读写过程
  5. PReLU与ReLU
  6. 腾讯人力资源管理体系
  7. QVector常见使用方法
  8. centos系统mysql数据库搭建教程
  9. 11 系统建模语言SysML实例——蒸馏器
  10. (笔记整理)公司vue平台用到redis,相关概念与登录(11)