Java tutorial
//package com.java2s; //License from project: Open Source License import android.view.View; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static Pattern RTL_CHAR = Pattern.compile("[\u0600-\u06FF\u0750-\u077F\u0590-\u05FF\uFE70-\uFEFF]"); public static int getTypeOfTextDirection(String text) { Matcher matcher = RTL_CHAR.matcher(text); if (matcher.find()) { return View.TEXT_DIRECTION_RTL; } else { return View.TEXT_DIRECTION_LTR; } } }