1,定义javascrip接口对象。
private class JsApi {
@JavascriptInterface<br />
public void onLoginCallback(String account, String token) {<br />
GLogger.e("lich", "from jsp:" + account + "," + token);
// send broadcast to ui process.
Intent it = new Intent(LoginCallbackReceiver.ACTION_LOGIN_CALLBACK);
it.putExtra(LoginCallbackReceiver.EXTRA_ACCOUNT, account);
it.putExtra(LoginCallbackReceiver.EXTRA_TOKEN, token);
getApplicationContext().sendBroadcast(it);
//
finish();
}
@JavascriptInterface
public String getAppSign() {
return AppManager.getAppSignEncodedByMd5(getApplicationContext());
}
}
2,在混淆文件proguard中配置:
-keepclassmembers class com.speektool.ui.activities.WebviewActivity$JsApi {
public *;
}
-keepattributes *JavascriptInterface*
-keepattributes *Annotation*