I have android project as quiz app , I need to run some code if user system lang is English , and another code if user system lang Arabic or other , how can I do that. I mean , if the lang eng run sound right answer , and if the lang is other run another sound of different lang.
public void checkAnswer(View view) {
Button answerBtn = (Button) findViewById(view.getId());
String btnText = answerBtn.getText().toString();
String alerTitle;
if (btnText.equals(rightAnswer)) {
alertTitle=(getString(R.string.rightAnswer));
rightAnswerCount++;
score.setText(String.valueOf(rightAnswerCount));
answerBtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.c));
mpright = MediaPlayer.create(MainActivity.this, R.raw.right_ans);
mpright.start();
Animation anm = AnimationUtils.loadAnimation(MainActivity.this, R.anim.abc_popup_exit);
answerBtn.startAnimation(anm);
} else {
alertTitle =getString(R.string.wrongAnswer);
wrongAnswerCount++;
wrong.setText(String.valueOf(wrongAnswerCount));
// wrongBtn.setBackgroundColor(Color.RED);
answerBtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.d));
mpwrong = MediaPlayer.create(MainActivity.this, R.raw.wronge_ans);
mpwrong.start();
Animation anm = AnimationUtils.loadAnimation(MainActivity.this, R.anim.abc_tooltip_enter);
answerBtn.startAnimation(anm);
}
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(alertTitle);
builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface p1, int p2) {
if (quizCount == Quiz_Count) {
Intent result = new Intent(getApplicationContext(), ResultActivity.class);
result.putExtra("Right_Answer_Count", rightAnswerCount);
startActivity(result);
} else {
quizCount++;
ShowNextQuiz();
}
}
});
builder.setCancelable(false);
builder.show();