I am using addJavascriptInterface in my app to popup a share window from Javascript.
Problem is : I can see pop up when I use my mobile in development environment. But the same in not working after publishing to Google and downloading. I am using Android 4.2 Jellybean mobile to test.
I have tried several ways but nothing worked.
---------onCreate----------
wvMainMenu = (WebView) findViewById(R.id.wvMainMenu);
wvMainMenu.getSettings().setJavaScriptEnabled(true);
wvMainMenu.getSettings().setLightTouchEnabled(true);
wvMainMenu.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
wvMainMenu.addJavascriptInterface(new WebappInterface(this), "Android");
-------Inside Javascript--------------
function share_it(id) {
Android.share_this(msg[id]);
}
-----WebappInterface.java--------
@JavascriptInterface public void share_this(String str) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
String sharedText = "Text to share " + str;
sendIntent.putExtra(Intent.EXTRA_TEXT, sharedText);
sendIntent.setType("text/plain");
mContext.startActivity(sendIntent);
}