translate yaparken catch bloğuna düşüyor
projemi daha önce paylaşmıştım ancak bu hata ilk kez geldi acaba google kütüphanesini kullanmama izin vermiyor mu 1 milyon karakter 20$ yazıyor deneme sürümü diye bişey yok mu acaba ya da başka bi sorun mu var
package com.example.ses;
import java.util.ArrayList;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;import com.google.api.GoogleAPI;
import com.google.api.translate.Language;
import com.google.api.translate.TranslateV2;
public class Ses extends Activity {protected static final int RESULT_SPEECH = 1;
private ImageButton btnSpeak;
private Button btnEnglish;
private TextView txtText, txtEnglish;
private static final String API_KEY = "AIzaSyB54CQs3a2W1hB_sS5SbuiAtdmAY1M6W6o";@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);txtText = (TextView) findViewById(R.id.txtText);
txtEnglish = (TextView) findViewById(R.id.txtEnglish);
btnEnglish = (Button) findViewById(R.id.btnEnglish);
btnSpeak = (ImageButton) findViewById(R.id.btnSes);
btnSpeak.setOnClickListener(new View.OnClickListener() {@Override
public void onClick(View v) {Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");try {
startActivityForResult(intent, RESULT_SPEECH);
txtText.setText("");
} catch (ActivityNotFoundException a) {
Toast.makeText(getApplicationContext(), "Üzgünüm Olmadı !",
Toast.LENGTH_SHORT).show();
}
}
});}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case RESULT_SPEECH: {
if (resultCode == RESULT_OK && null != data) {ArrayList<String> text = data
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);txtText.setText(text.get(0));
}
break;
}
}btnEnglish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
translate();
}private void translate() {
// TODO Auto-generated method stub
String inputString;
String outputString = null;
inputString = txtText.getText().toString();
try {
GoogleAPI.setKey(API_KEY);
outputString = TranslateV2.DEFAULT.execute(inputString,
Language.TURKISH, Language.ENGLISH);
GoogleAPI.setHttpReferrer("http://translate.google.com.en/");
} catch (Exception e) {
e.printStackTrace();
outputString = "Error";
Log.d("HATAAAAAAA", e.getMessage());
}txtEnglish.setText(outputString);
}
});
}
}
hata da şu şekilde
java.lang.Exception: [google-api-translate-java] Referrer is not set. Call setHttpReferrer().