test.php ファイルを使用して動作することを確認した HTTP サーバーにデータを送信するアプリを作成し、Android アプリとサーバーの間でデータが正常に渡されたことを確認しました。とにかく、別のデータ文字列を送信するようにソース コードを変更しました。
http://gamedemo.hostzi.com/apply.cgi?submit_button=Wireless_MAC&change_action=&action=Apply&wl_macmode=allow&wl_maclist=32&wait_time=3&wl_mac_filter=1&start=&wl_macmode1=allow&m0=00%3A1E%3A33%3AFE%3A0D%3A38&m16=00%3A00%3A00%3A00%3A00%3A00&m1=00%3A00%3A00%3A00%3A00%3A00&m17=00%3A00%3A00%3A00%3A00%3A00&m2=00%3A00%3A00%3A00%3A00%3A00&m18=00%3A00%3A00%3A00%3A00%3A00&m3=00%3A00%3A00%3A00%3A00%3A00&m19=00%3A00%3A00%3A00%3A00%3A00&m4=00%3A00%3A00%3A00%3A00%3A00&m20=00%3A00%3A00%3A00%3A00%3A00&m5=00%3A00%3A00%3A00%3A00%3A00&m21=00%3A00%3A00%3A00%3A00%3A00&m6=00%3A00%3A00%3A00%3A00%3A00&m22=00%3A00%3A00%3A00%3A00%3A00&m7=00%3A00%3A00%3A00%3A00%3A00&m23=00%3A00%3A00%3A00%3A00%3A00&m8=00%3A00%3A00%3A00%3A00%3A00&m24=00%3A00%3A00%3A00%3A00%3A00&m9=00%3A00%3A00%3A00%3A00%3A00&m25=00%3A00%3A00%3A00%3A00%3A00&m10=00%3A00%3A00%3A00%3A00%3A00&m26=00%3A00%3A00%3A00%3A00%3A00&m11=00%3A00%3A00%3A00%3A00%3A00&m27=00%3A00%3A00%3A00%3A00%3A00&m12=00%3A00%3A00%3A00%3A00%3A00&m28=00%3A00%3A00%3A00%3A00%3A00&m13=00%3A00%3A00%3A00%3A00%3A00&m29=00%3A00%3A00%3A00%3A00%3A00&m14=00%3A00%3A00%3A00%3A00%3A00&m30=00%3A00%3A00%3A00%3A00%3A00&m15=00%3A00%3A00%3A00%3A00%3A00&m31=00%3A00%3A00%3A00%3A00%3A00&end=
データを渡していません!理由はありますか?
ps
チュートリアルを使用しましたが、ソースを編集して特定のデータ文字列を送信すると、テキスト フィールドに入力されたテキスト (使用する必要がなくなりました) の代わりに、ソース コードを解体したように見えます。
チュートリアル:
http://mobiledevtuts.com/android/android-http-with-asynctask-example/
import android.app.Activity;
import android.app.AlertDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.ViewGroup;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TimePicker;
import android.widget.Toast;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.opengl.Visibility;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.nfc.linkingmanager.DeviceConfig.MyAsyncTask;
public class AddEditCountry extends Activity {
private long rowID;
private EditText nameEt;
private EditText capEt;
private EditText codeEt;
private TimePicker timeEt;
public class DeviceConfig extends Activity implements OnClickListener{
private EditText value;
private Button btn;
private ProgressBar pb;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.deviceconfig);
value=(EditText)findViewById(R.id.editText1);
btn=(Button)findViewById(R.id.button1);
pb=(ProgressBar)findViewById(R.id.progressBar1);
pb.setVisibility(View.GONE);
btn.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onClick(View v) {
// TODO Auto-generated method stub
if(value.getText().toString().length()<1){
// out of range
Toast.makeText(this, "please enter something", Toast.LENGTH_LONG).show();
}else{
pb.setVisibility(View.VISIBLE);
new MyAsyncTask().execute(value.getText().toString());
}
}
private class MyAsyncTask extends AsyncTask<String, Integer, Double>{
@Override
protected Double doInBackground(String... params) {
// TODO Auto-generated method stub
postData(params[0]);
return null;
}
protected void onPostExecute(Double result){
pb.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "command sent", Toast.LENGTH_LONG).show();
}
protected void onProgressUpdate(Integer... progress){
pb.setProgress(progress[0]);
}
public void postData(String valueIWantToSend) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://admin:admin@192.168.1.1/apply.cgi");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("submit_button", "Wireless_MAC");
nameValuePairs.add(new BasicNameValuePair("change_action", "");
nameValuePairs.add(new BasicNameValuePair("action", "Apply");
nameValuePairs.add(new BasicNameValuePair("wl_macmode", "allow");
nameValuePairs.add(new BasicNameValuePair("wl_maclist", "32");
nameValuePairs.add(new BasicNameValuePair("wait_time", "3");
nameValuePairs.add(new BasicNameValuePair("wl_mac_filter", "1");
nameValuePairs.add(new BasicNameValuePair("start", "allow");
nameValuePairs.add(new BasicNameValuePair("wl_macmode1", "allow");
nameValuePairs.add(new BasicNameValuePair("m0", "00%3A1E%3A33%3AFE%3A0D%3A38");
nameValuePairs.add(new BasicNameValuePair("m16", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m1", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m17", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m2", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m18", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m3", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m19", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m4", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m20", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m5", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m21", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m6", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m22", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m7", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m23", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m8", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m24", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m9", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m25", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m10", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m26", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m11", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m27", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m12", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m28", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m13", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m29", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m14", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m30", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m15", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("m31", "00%3A00%3A00%3A00%3A00%3A00");
nameValuePairs.add(new BasicNameValuePair("end", "");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.add_country);
nameEt = (EditText) findViewById(R.id.nameEdit);
capEt = (EditText) findViewById(R.id.capEdit);
codeEt = (EditText) findViewById(R.id.codeEdit);
timeEt = (TimePicker) findViewById(R.id.timeEdit);
Bundle extras = getIntent().getExtras();
if (extras != null)
{
rowID = extras.getLong("row_id");
nameEt.setText(extras.getString("name"));
capEt.setText(extras.getString("cap"));
codeEt.setText(extras.getString("code"));
String time = extras.getString("time");
String[] parts = time.split(":");
timeEt.setCurrentHour(Integer.valueOf(parts[0]));
timeEt.setCurrentMinute(Integer.valueOf(parts[1]));
timeEt.setIs24HourView(false);
DecimalFormat df = new DecimalFormat ("00");
String minutes = df.format(min);
}
Button saveButton =(Button) findViewById(R.id.saveBtn);
saveButton.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
if (nameEt.getText().length() != 0)
{
AsyncTask<Object, Object, Object> saveContactTask =
new AsyncTask<Object, Object, Object>()
{
@Override
protected Object doInBackground(Object... params)
{
saveContact();
return null;
}
@Override
protected void onPostExecute(Object result)
{
finish();
}
};
saveContactTask.execute((Object[]) null);
}
else
{
AlertDialog.Builder alert = new AlertDialog.Builder(AddEditCountry.this);
alert.setTitle(R.string.errorTitle);
alert.setMessage(R.string.errorMessage);
alert.setPositiveButton(R.string.errorButton, null);
alert.show();
}
}
});
}
private void saveContact()
{
DatabaseConnector dbConnector = new DatabaseConnector(this);
if (getIntent().getExtras() == null)
{
dbConnector.insertContact(nameEt.getText().toString(),
capEt.getText().toString(),
timeEt.getCurrentHour().toString() + ":"
+ timeEt.getCurrentMinute().toString(),
codeEt.getText().toString());
}
else
{
dbConnector.updateContact(rowID,
nameEt.getText().toString(),
capEt.getText().toString(),
timeEt.getCurrentHour().toString() + ":"
+ timeEt.getCurrentMinute().toString(),
codeEt.getText().toString());
}
}
}}}
問題:
Description Resource Path Location Type
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 139 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 138 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 137 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 136 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 143 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 142 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 141 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 140 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 147 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 146 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 145 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 144 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 151 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 150 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 149 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 148 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 154 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 155 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 152 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 153 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 158 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 159 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 156 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 157 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 162 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 163 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 160 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 161 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 166 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 167 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 164 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 165 Java Problem
The method onCreate(Bundle) is undefined for the type AsyncTask<String,Integer,Double> AddEditCountry.java /TEST App/src/com/app/test line 187 Java Problem
The constructor DatabaseConnector(AddEditCountry.DeviceConfig.MyAsyncTask) is undefined AddEditCountry.java /TEST App/src/com/app/test line 258 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 169 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 168 Java Problem
The method onCreate(Bundle) of type AddEditCountry.DeviceConfig.MyAsyncTask must override or implement a supertype method AddEditCountry.java /TEST App/src/com/app/test line 185 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 170 Java Problem
The type com.test.app.DeviceConfig.MyAsyncTask is not visible AddEditCountry.java /TEST App/src/com/app/test line 57 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 129 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 130 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 131 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 132 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 133 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 134 Java Problem
Syntax error, insert ")" to complete Expression AddEditCountry.java /TEST App/src/com/app/test line 135 Java Problem
PS
提案された行に ) を追加しようとすると、問題ログにさらに多くの問題が追加されるだけです。: (
送信ボタンをクリックすると、テキスト ボックスにデータが含まれている必要があります。自分のデータのみを送信し、可能であればこの要件を削除したい