UnsupportedOperationException using paint.getTextBounds
I got following error message:

    main.xml: java.lang.UnsupportedOperationException

Stacktrace says:

    java.lang.UnsupportedOperationException
	at android.graphics.Paint_Delegate.nativeGetStringBounds(Paint_Delegate.java:897)
	at android.graphics.Paint.nativeGetStringBounds(Paint.java)
	at android.graphics.Paint.getTextBounds(Paint.java:1798)

Within my code I have set up a simple test case to figure out where the problem is:

    public class test extends View {

	public test(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public test(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public test(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}
	
	protected void onDraw(Canvas canvas){
		super.onDraw(canvas);
		
		Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
		p.setColor(Color.GREEN);
		p.setTextAlign(Align.CENTER);
		
		canvas.drawText("hello", 100, 100, p);
		
		Rect bounds = new Rect();
	    p.getTextBounds("2", 0, 1, bounds);
	}
	
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}
}

Any ideas what is going wrong?
UnsupportedOperationException using paint.getTextBounds
===

I got following error message:

    main.xml: java.lang.UnsupportedOperationException

Stacktrace says:

    java.lang.UnsupportedOperationException
	at android.graphics.Paint_Delegate.nativeGetStringBounds(Paint_Delegate.java:897)
	at android.graphics.Paint.nativeGetStringBounds(Paint.java)
	at android.graphics.Paint.getTextBounds(Paint.java:1798)

Within my code I have set up a simple test case to figure out where the problem is:

    public class test extends View {

	public test(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public test(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public test(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}
	
	protected void onDraw(Canvas canvas){
		super.onDraw(canvas);
		
		Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
		p.setColor(Color.GREEN);
		p.setTextAlign(Align.CENTER);
		
		canvas.drawText("hello", 100, 100, p);
		
		Rect bounds = new Rect();
	    p.getTextBounds("2", 0, 1, bounds);
	}
	
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}
}

Any ideas what is going wrong?