@SuppressLint
(
"SetJavaScriptEnabled"
)
public
class
MainActivity
extends
CordovaActivity {
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
WebSettings webSettings =
super
.appView.getSettings();
webSettings.setJavaScriptEnabled(
true
);
super
.appView.addJavascriptInterface(
new
MyJavascriptInterface(),
"android"
);
}
private
class
MyJavascriptInterface {
@JavascriptInterface
public
void
doHtml() {
new
Handler().post(
new
Runnable() {
public
void
run() {
Intent intent =
new
Intent(Intent.ACTION_VIEW);
startActivity(intent);
}
});
}
@JavascriptInterface
public
void
doKakao(
final
String subject,
final
String content) {
new
Handler().post(
new
Runnable() {
public
void
run() {
Intent shareIntent =
new
Intent (android.content.Intent.ACTION_SEND);
shareIntent.setType(
"text/plain"
);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
shareIntent.putExtra(Intent.EXTRA_TEXT, content);
shareIntent.setType(
"image/png"
);
shareIntent.setPackage(
"com.kakao.talk"
);
startActivity(Intent.createChooser(shareIntent, subject));
}
});
}
}
}