PHP to android using HTTPpost [closed] - android

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
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.

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(new JavaScriptInterface(), "Android");
in HTML:
<button onclick="appTest('test');return false;">test-button</button>
in Javascript:
function appTest(args) {
if (typeof Android != "undefined"){
if (Android.appTest!= "undefined") {
Android.appTest(args);
}
}
}
and finally in Android:
class JavaScriptInterface {
public void appTest(String s) {
//do something
}
}
EDIT:
Sorry, didn't see HTTPpost in the header

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

Related

How do I send push notification on Android depending on the data from a REST API using Firebase? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have successfully setup Firebase and my Android app to work together. I can send notification from the Firebase console and receive perfectly. But, that's not what I want, I want to send notification depending on the data I receive from a REST API in JSON format(I'm using the USGS API). So I would like to notify my users when a major earthquake takes place. How do I achieve this? I'm pretty new to all this, it would be great if you could help me out.
Once you implement Firebase in your app, you will receive refreshedToken, you need to send this to your Web Server so it has the updated token.
And implement a your own section on web to send Push notification with help from following process
https://firebase.google.com/docs/cloud-messaging/admin/send-messages
You can achieve your goal using node.js script.
Just follow below instructions:
1. install fcm node
npm install fcm-node
paste below code & save file with name say "fcm_demo" with .js extension
var FCM = require('fcm-node');
var serverKey = 'YOURSERVERKEYHERE'; //put your server key here
var fcm = new FCM(serverKey);
var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)
to: 'registration_token',
data: { //you can send only notification or only data(or include both)
my_key: 'my value',
my_another_key: 'my another value'
}
};
fcm.send(message, function(err, response)
{
if (err)
{
console.log("Something has gone wrong!");
}
else
{
console.log("Successfully sent with response: ", response);
}
});
Few points to remember :-
You will get your server key from Firebase Console where you have registered your Project. (Just search there..).
You will get registration token from refreshedToken.
Before installing fcm-node, your machine must have pre-installed node.js and npm. If you don't have node.js and npm previously installed, first install those components & then install fcm-node.
As you want to send notification depending on the data you receive from a REST API in JSON format, just copy your JSON format in data section of above node.js script.
Run above script from terminal as
node fcm_demo.js
If everything goes well, you will receive your notification.
Thanks. ;)

How to send a URL in email using Android Intents

I'm trying to send a market URL (for eg- market://details?id=com.android.chrome) to a helper app in an email using Intents. I tried using SpannableStringbuilder to ember the URL as proposed in Stack overflow answer and I also tried to use Html.fromHtml as proposed in this blog post
In both the cases, I'm able to send the email but email received does not have any URL. while sending the email I use Gmail as the application for sending the email.
It seems like both the options were proposed a few years ago. Is there a more current way to do this ?
thanks

Right approach for simple Android app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've been studying a lot about Android development recently and to really get the feeling of it, I want to start building a simple application that would get me going. Unfortunately, I think the more I read, the more confused I get.
I want to build an app that scans and reads a bar code, queries a RESTful web service with the EAN read from the bar code and outputs the name of the product.
Now, the scanning part was easy, as I used the zxing library as an intent service. Then, I played a lot with a framework called Volley which is supposed to handle the network communication with the web service and parsing the JSON result. Unfortunately, I wasn't able to integrate Volley with my app, but maybe this handy tool is more than I actually need.
What would be the right approach to achieve the above goal? Do I need a content provider? Do I need a service? How would these relate to each other?
I haven't worked with Volley myself, so I can't give you an answer if it's too advanced for what you want to achieve. In general when it comes to HTTP communication with a server I prefer to use AndroidAsyncHttpClient:
"An asynchronous callback-based Http client for Android built on top of Apache’s HttpClient libraries. All requests are made outside of your app’s main UI thread, but any callback logic will be executed on the same thread as the callback was created using Android’s Handler message passing."
Example relevant to what you want to do:
public class YourActivity extends Activity {
private void handleScannedBardcode(String barcode) {
// you need to make the request match the REST API you are using
RequestParams params = new RequestParams();
params.put("A_KEY_TO_IDENTIFY_THE_PARAMETER", barcode);
AsyncHttpClient client = new AsyncHttpClient();
client.post("http://www.yourserver.com", params, new AsyncHttpResponseHandler() {
#Override
public void onSuccess(String response) {
// you need to add parsing of JSON data to match the response
JSONObject jo = new JSONObject(response);
String productName = jo.getString("productname");
updateProductView(productName);
}
});
}
private void updateProductView(String productName) {
// you need to use a view id that corresponds to a textview in your layout xml
TextView tv = (TextView)findViewById(R.id.productName);
tv.setText(productName);
}
}
Depending on how complex the JSON response is you can either opt for GSON or Jackson for parsing of large amounts of JSON or plain JSONObject
I use this library to handle the communication with my API: https://github.com/koush/ion
It's easy to use, has samples and code examples.
Go with simple solution first:
use HttpURLConnection to connect with web service,
then use either InputStreamReader or BufferedInputStream to read the input stream from the connection.
Create a JSON model class similar to the one you get from your web service.
Use Google GSON library to parse the response into a JSONResponse and then use the data.
I'm sure you'll be able to find enough help on SO regarding these individual points to get you started.

Send Message Using GCM [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to know whether it is possible for sending a notification from one android mobile to android mobile via a local server?
You don't need a server.
Send: Your phone can perform a HTTP POST to Google's servers of some JSON describing the sender/registration ids (along with the message), which then passes the message to the target device(s). Details here: http://developer.android.com/google/gcm/c2dm.html
Note that that page describes migration from C2DM to GCM. What i'm suggesting here is the new GCM method. Base your JSON on the last example on that page:
Content-Type:application/json
Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA
{
"registration_id" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
"data" : {
"Team" : "Portugal",
"Score" : "3",
"Player" : "Varela",
},
}
Receive: using Google's GCM system to receive via intents as described here: http://developer.android.com/google/gcm/client.html
I want to know whether it is possible for sending a message from one android mobile to another using GCM ?
Yes , it is possible.
Can android mobile act as server to post message via GCM?
No , You will need to use 3rd party server to communicate between two mobile phones.
Full information is available here.

How can I get post back response using webview in android?

Currently I am working on payment integration for native android app after send the request it have given me post back url with some attributes as success/fail response. I can't understand that how can I get those post back url attributes values using WebView . If any one know,
Please suggest me some idea for that.

Categories

Resources