Skip to content Skip to sidebar Skip to footer

Php To Android Using Httppost

Is there a way to send the selected data from my website to an android application? I want to use the data selected to use on conditions in android.Thanks in advance.

Solution 1:

If you use WebView to load the webpage, you can invoke a native-method by using the JavaScriptInterface. For example:

Bind the JavascriptInterface to your WebView in Android:

webView.addJavascriptInterface(newJavaScriptInterface(), "Android");

in HTML:

<buttononclick="appTest('test');return false;">test-button</button>

in Javascript:

functionappTest(args) {
 if (typeofAndroid != "undefined"){ 
   if (Android.appTest!= "undefined") {
    Android.appTest(args);
   }
 }
}

and finally in Android:

classJavaScriptInterface {

  publicvoidappTest(String s) {
     //do something
  }
}

EDIT:

Sorry, didn't see HTTPpost in the header

Solution 2:

Nope , It is not possible to send data using httppost from server to android.

Approach 1:

For this kind of data transmission you need to implement socket programming both the side. Like : XMPP Server(Openfire);

Approac 2:

1) Implement push notification at device side.

2) Make one webservice at server side which will return response(whatever you want to send to mobile side).

3) Fire pushnotification from your server to google server and google server will send that push to android device.

4) When android receive push it will call the webservice of your server and will get the date that you want to send.

We are using Second approach in our application IjoomerAdvance.

Refer this link for Google push implementation between android and php

http://androidexample.com/Android_Push_Notifications_using_Google_Cloud_Messaging_GCM/index.php?view=article_discription&aid=119&aaid=139

Post a Comment for "Php To Android Using Httppost"