Indic Languages are not showing in Android 4.2.2

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Aug 8, 2014 4:41:56 PM via Website

I am developing an android application. It is very simple I have a website and I want to load that through android application. In the website I have used unicode character of raavi font. It is a unicode font. My application is perfectly working in 4.0, 4.1 android versions. It shows me the unicode characters in webview.. But when I run my application in android 4.2.2, surprisingly it only shows English letters not other unicode characters.. Is there any fix for 4.2.2? Please help my .java code file code is given below: Please help.... only this is the problem.....

public class MainActivity extends Activity 
{
    WebView mWeb;
    ProgressDialog mProgress;
    Boolean isInternetPresent = false;
    ConnectionDetector cd;

    @SuppressLint("SetJavaScriptEnabled") 
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        cd = new ConnectionDetector(getApplicationContext());
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        mWeb = new WebView(this);
        mWeb.setClickable(true);
        mWeb.setFocusableInTouchMode(true);
        setContentView(mWeb);
        WebSettings settings = mWeb.getSettings();
        mWeb.getSettings().setDefaultTextEncodingName("utf-8");
        settings.setJavaScriptEnabled(true);


mWeb.loadUrl("address of the website");


       //Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Jatt_Ekta04.ttf");
      // mWeb.setTypeface(font);


        mWeb.setWebViewClient(new WebViewClient() {
        //  ProgressDialog mProgress = null;

            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }



            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
                isInternetPresent = cd.isConnectingToInternet();
                if (isInternetPresent) {
                    // Internet Connection is Present
                    // make HTTP requests
                    mProgress = new ProgressDialog(MainActivity.this);
                    //mProgress.setTitle("Please Wait!");
                    mProgress.setMessage("Loading Data...");
                    mProgress.show();
                } else {
                    // Internet connection is not present
                    // Ask user to connect to Internet
                    showAlertDialog(MainActivity.this, "No Internet Connection",
                            "Failed to Load Database....", false);
                    finish();
                }       
            }

            public void onPageFinished(WebView view, String url) {
                if(mProgress.isShowing()) {
                    mProgress.hide();
                    mProgress.dismiss();
                }
            }
        });

       //
    }

    @Override  
    public boolean onCreateOptionsMenu(Menu menu) {  
        // Inflate the menu; this adds items to the action bar if it is present.  
        getMenuInflater().inflate(R.menu.menu_main, menu);//Menu Resource, Menu  
        return true;  
    }  

    @Override  
    public boolean onOptionsItemSelected(MenuItem item) {  
        switch (item.getItemId()) {  
            case R.id.item1:  
              Intent j = new Intent(MainActivity.this, AboutActivity.class);
              startActivity(j);
            return true;     

            case R.id.item2:  
                mWeb.loadUrl("Javascript:window.location.reload(true)");
              return true;     

            case R.id.item3:  
                finish();
              return true; 

              default:  
                return super.onOptionsItemSelected(item);  
        }  
    }  


    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && mWeb.canGoBack())
        {
            mWeb.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

/**
 * Function to display simple Alert Dialog
 * @param context - application context
 * @param title - alert dialog title
 * @param message - alert message
 * @param status - success/failure (used to set icon)
 * */
//@SuppressWarnings("deprecation")
public void showAlertDialog(Context context, String title, String message, Boolean status) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();

    // Setting Dialog Title
    alertDialog.setTitle(title);

    // Setting Dialog Message
    alertDialog.setMessage(message);

    // Setting alert dialog icon
    alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);

    // Setting OK Button
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int which) {
      }
   });

    // Showing Alert Message
    alertDialog.show();
}
}