android JNI乱码
16lz
2021-01-23
在JNI中难免会遇到中文乱码的问题,这里是解决部分乱码的一个简单示例,留作备忘
public class HelloWorld1 extends Activity { /** Called when the activity is first created. */static {System.loadLibrary("Hello");}public native String helloFromJNI(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } //按钮的点击事件 public void click (View view){ try {String s = helloFromJNI();String s1= new String(s.getBytes("iso8859-1"), "UTF-8" ) ; //主要是这里的处理,处理从接口中拿到的StringToast.makeText(this, s , 1).show();} catch (UnsupportedEncodingException e) {// TODO Auto-generated catch blocke.printStackTrace();} }}
更多相关文章
- Android带进度条的下载图片示例(AsyncTask异步任务)
- android代码示例讲解--专题视频课程
- android 自定义View类的简单使用 示例
- android 服务概述 本地服务示例
- android下歌曲名称乱码的解决办法
- android app 示例 SQLiteOpenHelper 实现数据操作
- android studio 弹窗中文乱码
- (4.2.15.1)【android开源工具】安卓图表引擎AChartEngine(三) - 示