so I have this CanvasView which shows debugging information of my app. Its basically overlayed view with transparant background so everything drawn in the canvas is floating in the screen. Since I need some information from native c++ which returns wchar_t*, how can I use env->NewString
since android now makes wchar_t is 4 bytes while jchar is 2 bytes?
My java code that calls native c++ function in my lib:
private static String get_Name();
private class CanvasView extends View{
public CanvasView(Context context){
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paintText = new Paint();
paintText.setStyle(Paint.Style.FILL);
paintText.setColor(Color.WHITE);
paintText.setShadowLayer(5.5f, 0, 0, Color.BLACK);
paintText.setTextSize(convertSizeToDp(7.5f));
paintText.setTextAlign(Paint.Align.LEFT);
paintText.drawText(get_Name(), x, y, paintText);
// the rest of the code
// ...
}
}
get_Name
basically return a jstring which come from NewString((const jchar* )myWchar, myLen)
The return results sometimes are non unicode string or even my app is crashing when NewString
is called.