Vinraj
Vinraj

Reputation: 141

Autoclick html button from Java in Android

I am writing an App in Eclipse for Android. The App constantly communicates with contents in a Web Server. In the Server, I have a html file which has another button. I wish that When I press the button in my Android App, the button in the html file is autoclicked..Is it possible. Please suggest..

I see that with the below code(jquery):

$(".press").trigger('click');

autoclick of html button is achieved but how do i do that from java in android..?

Thanks

Upvotes: 2

Views: 1163

Answers (1)

Jayyrus
Jayyrus

Reputation: 13061

just use javascript:

yourButton.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v) {
        yourWebView.loadUrl("javascript:clickHtmlButton()");
    }
});

javascript:

function clickHtmlButton(){
   $(".press").click();
}

Upvotes: 2

Related Questions