HundredsServer.java 793 B

123456789101112131415161718192021222324252627282930313233343536
  1. package community.peers.hundreds;
  2. import android.content.Context;
  3. import android.webkit.JavascriptInterface;
  4. import android.widget.Toast;
  5. /**
  6. * Created by asap on 7/14/15.
  7. */
  8. public class HundredsServer {
  9. Context mContext;
  10. HundredsServer(Context c) {
  11. mContext = c;
  12. }
  13. @JavascriptInterface
  14. public void printToToast(String webMessage)
  15. {
  16. final String theAnswer = "Toast hears " + webMessage + "!";
  17. Toast.makeText(mContext, theAnswer, Toast.LENGTH_SHORT).show();
  18. }
  19. @JavascriptInterface
  20. public String printToHtml(String webMessage)
  21. {
  22. final String theAnswer = "Html hears " + webMessage + "!";
  23. return theAnswer;
  24. }
  25. //Put your own API here.
  26. //Make sure to annotate each one with @JavascriptInterface
  27. }