Should I use PhoneGap instead of ramping up on the Android SDK?

前端 未结 5 1165
陌清茗
陌清茗 2021-01-30 17:36

Although I am comfortable with Java, I have much more experience with web development. I am looking to get into programming simple Android games.

Should I just program e

5条回答
  •  天涯浪人
    2021-01-30 18:03

    The biggest pro for phonegap is that it takes advantage of your web development experience. I think what most people seem to miss (or ignore) is that there is no advantage in avoiding phonegap for an android only application! You can still write as much native code as you want to, mixing and matching phonegap as you please.

    I am writing an Android app that uses text to speech. Because Phonegap doesn't support this in their API, you might think that Phonegap is a bad choice, but actually it was quite easy to call the Java code I need from javascript:

    Java code:

    public void onCreate(Bundle savedInstanceState) {
       //boilerplate and TTS set up
        ...
        this.appView.addJavascriptInterface(this.speak, "speak");
        ...
    }
    
    public void speak(String text) {
        this.tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
    }
    

    Javascript code:

    speak.say("hello world");
    

提交回复
热议问题