Search code examples
androidtensorflow-lite

Can i get the drawText(text) value and print it to Toast.makeText(text)


It is possible to get the value of text on

 public String drawText(
      final Canvas canvas, final float posX, final float posY, final String text, Paint bgPaint) {

float width = exteriorPaint.measureText(text);
float textSize = exteriorPaint.getTextSize();
Paint paint = new Paint(bgPaint);
paint.setStyle(Style.FILL);
//paint.setAlpha(160);
canvas.drawRect(posX, (posY + (int) (textSize) + overlap), (posX + (int) (width) + 2*overlap), posY, paint);

//VALUE ARE HERE
canvas.drawText(text, posX + overlap, (posY + textSize), interiorPaint);}

The problem is I want to get the value of text and use it to Toast.maketext()


Solution

  • You can just use the following method to show toast from drawText method.

    //Here pass your Application-level Context,

    Toast.makeText(App.getInstant(), text, Toast.LENGTH_SHORT).show()
    

    See this link for creating static instant to fetch application context