你看到这段代码有什么问题吗?函数执行时出现以下错误:java.lang.NullPointerException: Attempt to invoke interface method java.lang.Object[] java.util.Set.toArray()on a null object reference。我在 Android 7.0 中运行它。
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import java.util.Locale;
import java.util.Set;
import java.util.Arrays;
import android.content.Context;
public static String GetLanguages(Object objcon) {
Context context = (Context) objcon;
TextToSpeech tts;
tts = new TextToSpeech(context, new OnInitListener(){
@Override
public void onInit(int status) {
};
});
Set<Locale> loc = tts.getAvailableLanguages();
Object[] objloc = loc.toArray();
return Arrays.toString(objloc);
};
POPMUISE
Helenr
相关分类