Zhambul
Zhambul

Reputation: 942

Unmappable character for encoding UTF-8 in Android Studio

I'm developing an Android app in the Russian language.

Here is my AlertMessage class with only one method and one Russian word within:

public class AlertMessage {

public static boolean isYes (Context context, String header, String message){
    final boolean[] isYes = {false};
    new AlertDialog.Builder(context)
            .setTitle(header)
            .setMessage(message)
            .setNegativeButton(android.R.string.no, null)
            .setPositiveButton("Да",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface arg0, int arg1) {

                            isYes[0] =  true;

                        }
                    }).create().show();
    return isYes[0];
}
}

And I call it from the MainActivity:

 @Override
public void onBackPressed(){

    if(AlertMessage.isYes(this,"Выход","Вы уверены, что хотите выйти из аккаунта?"))
    {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        App.super.onBackPressed();
        Log.i("App", "Exit");
        finish();
    }
}

Everything work fine except one Russian word in AlertMessage class. It is unreadable. How can I fix it?

Upvotes: 2

Views: 2852

Answers (1)

Stepango
Stepango

Reputation: 4841

You could fix it by using strings from resources like getString(R.string.error_msg) instead of hardcoded string.

Upvotes: 6

Related Questions