Click here to Skip to main content
14,453,485 members
   

Android

 
QuestionListview item to textview Pin
Member 140794445-Dec-18 21:46
MemberMember 140794445-Dec-18 21:46 
AnswerRe: Listview item to textview Pin
Richard MacCutchan5-Dec-18 23:12
communityengineerRichard MacCutchan5-Dec-18 23:12 
GeneralRe: Listview item to textview Pin
Member 140794446-Dec-18 0:45
MemberMember 140794446-Dec-18 0:45 
GeneralRe: Listview item to textview Pin
Richard MacCutchan6-Dec-18 1:24
communityengineerRichard MacCutchan6-Dec-18 1:24 
QuestionRe: Listview item to textview Pin
David Crow6-Dec-18 5:52
MemberDavid Crow6-Dec-18 5:52 
QuestionPOSTING DATA FROM ANDROID TO PHP SERVER Pin
Member 1407048128-Nov-18 5:47
MemberMember 1407048128-Nov-18 5:47 
QuestionRe: POSTING DATA FROM ANDROID TO PHP SERVER Pin
David Crow29-Nov-18 18:46
MemberDavid Crow29-Nov-18 18:46 
AnswerRe: POSTING DATA FROM ANDROID TO PHP SERVER Pin
GiteHrudaya14-Dec-18 1:17
MemberGiteHrudaya14-Dec-18 1:17 
It is very important for a mobile application too talk to web based applications. There are various scenarios where we need to fetch data from web pages .

The code below will enable your android app to talk to a webpage.

Note : You also need to enable uses permission for internet in the android.manifest file.

<uses-permission
        android:name="android.permission.INTERNET" />
Code for android app


public void postData(String toPost) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.URL.com/yourpage.php");

//This is the data to send
String MyName = 'adil'; //any data to send

try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("action", MyName));

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

// Execute HTTP Post Request

ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpclient.execute(httppost, responseHandler);

//This is the response from a php application
String reverseString = response;
Toast.makeText(this, "response" + reverseString, Toast.LENGTH_LONG).show();

} catch (ClientProtocolException e) {
Toast.makeText(this, "CPE response " + e.toString(), Toast.LENGTH_LONG).show();
// TODO Auto-generated catch block
} catch (IOException e) {
Toast.makeText(this, "IOE response " + e.toString(), Toast.LENGTH_LONG).show();
// TODO Auto-generated catch block
}

}//end postData()

php code

<?php

//code to reverse the string

$reversed = strrev($_POST["action"]);

echo $reversed;

?>


modified 29-Dec-18 2:08am.

AnswerRe: POSTING DATA FROM ANDROID TO PHP SERVER Pin
GiteHrudaya27-Dec-18 23:31
MemberGiteHrudaya27-Dec-18 23:31 
QuestionDetect VPN From Android App Pin
Kevin Marois26-Nov-18 5:04
professionalKevin Marois26-Nov-18 5:04 
AnswerRe: Detect VPN From Android App Pin
Richard MacCutchan26-Nov-18 6:04
communityengineerRichard MacCutchan26-Nov-18 6:04 
GeneralRe: Detect VPN From Android App Pin
Kevin Marois26-Nov-18 6:25
professionalKevin Marois26-Nov-18 6:25 
GeneralRe: Detect VPN From Android App Pin
Richard MacCutchan26-Nov-18 7:53
communityengineerRichard MacCutchan26-Nov-18 7:53 
GeneralRe: Detect VPN From Android App Pin
Kevin Marois26-Nov-18 8:26
professionalKevin Marois26-Nov-18 8:26 
QuestionRe: Detect VPN From Android App Pin
David Crow26-Nov-18 8:50
MemberDavid Crow26-Nov-18 8:50 
AnswerRe: Detect VPN From Android App Pin
Kevin Marois26-Nov-18 10:12
professionalKevin Marois26-Nov-18 10:12 
QuestionRe: Detect VPN From Android App Pin
David Crow26-Nov-18 10:17
MemberDavid Crow26-Nov-18 10:17 
AnswerRe: Detect VPN From Android App Pin
Kevin Marois26-Nov-18 10:21
professionalKevin Marois26-Nov-18 10:21 
SuggestionRe: Detect VPN From Android App Pin
David Crow26-Nov-18 10:26
MemberDavid Crow26-Nov-18 10:26 
GeneralRe: Detect VPN From Android App Pin
Kevin Marois26-Nov-18 12:00
professionalKevin Marois26-Nov-18 12:00 
GeneralRe: Detect VPN From Android App Pin
Mycroft Holmes26-Nov-18 14:47
MemberMycroft Holmes26-Nov-18 14:47 
GeneralRe: Detect VPN From Android App Pin
Richard MacCutchan26-Nov-18 22:14
communityengineerRichard MacCutchan26-Nov-18 22:14 
QuestionRe: Detect VPN From Android App Pin
David Crow26-Nov-18 7:54
MemberDavid Crow26-Nov-18 7:54 
AnswerRe: Detect VPN From Android App Pin
Kevin Marois26-Nov-18 8:26
professionalKevin Marois26-Nov-18 8:26 
QuestionExpandableListView ChildView button click event fires on multiple ChildView buttons Pin
GuyThiebaut17-Nov-18 6:57
professionalGuyThiebaut17-Nov-18 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.