Specifying a port in HttpPost

by drill » Sat, 27 Feb 2010 18:36:27 GMT


Sponsored Links
 I want to make a Http-post-request to a webserver on a specific port.
For that I use the HttpPost constructor as follows:
HttpPost post = new HttpPost(" http://webpage.com :1212/httppost.php");
Then I put some parameters with it using
post.setEntity(params);
When I now want to execute that request with
HttpResponse response = client.execute(post);
I receive a NoHttpResponseException.
The server is available and when I try all that without a port I don't
get that exception, but I need to specify my port. Is there anybody
who had a similar problem or do have a solution for me?

Thanks a lot.
regards

--



Other Threads

1. A ListView that acts like RadioButtons

I get a list of choices from an external server. Sometimes this list
is long so using actual radio buttons is ugly. The user can only pick
one item from the list. I'd like the ListView to act just like
RadioButtons - one item in the list is highlighted and if a different
item is picked then that item is highlighted and the previous choice
is unhighlighted. Can this be done?

-- 

2. Audio Record problem (urgent)

Hi all
I'm an android starter
I used MediaRecorder and MediaPlayer to record voice via mic before
This time,I try AudioRecord and  AudioTrack to record voice
But when I try to start, it's forced to be shut down
I've no idea where is wrong?
here are my code ~
Could any one tell me why?
TKS in advance :)

public class audioRecorderTest2 extends Activity
{

        boolean isRecording = true;

        private static final String Tag = "audioRecorder";
        private static final boolean log = true;

        Button recordButton;
        Button stopButton;

        OnClickListener record_listener = null;
        OnClickListener stop_listener = null;

        int frequency = 8000;
        int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
        int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;

        protected static final int MENU_ABOUT = Menu.FIRST;
        protected static final int MENU_Quit = Menu.FIRST + 1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        initResourceRefs();

        setTitle("Audio recorder test...");

        record_listener = new OnClickListener()
            {
                @Override
                public void onClick(View arg0)
                {
                        AudioManager am =
(AudioManager)getSystemService(Context.AUDIO_SERVICE);

                        //int actualBufferSize = 4096*8;

                        int bufferSize =
AudioTrack.getMinBufferSize(frequency,channelConfiguration,audioEncoding);

                        int actualBufferSize = bufferSize;//4096*8

                        AudioTrack audioTrack = new
AudioTrack(AudioManager.STREAM_MUSIC,
                                                                       
frequency,
                                                                       
channelConfiguration,
                                                               audioEncoding,
                                                               actualBufferSize,
        
AudioTrack.MODE_STREAM);

                        byte[] buffer = new byte[actualBufferSize];

                        AudioRecord audioRecord = new
AudioRecord(MediaRecorder.AudioSource.MIC,
                                                                          
frequency,
                                                                          
channelConfiguration,
                                                                          
audioEncoding,
                                                                  
actualBufferSize);

                        am.setRouting(AudioManager.MODE_NORMAL,
                                      AudioManager.ROUTE_EARPIECE,
                                      AudioManager.ROUTE_ALL);

                        am.setSpeakerphoneOn(true);
                        am.setMicrophoneMute(false);

                        Log.d(Tag,"Is speakerphone on? : " + 
am.isSpeakerphoneOn());

                        audioTrack.setPlaybackRate(frequency);
                        audioRecord.startRecording();
                        audioTrack.play();

                        int frameSize = bufferSize;//320

                        while(isRecording == true)
                        {
                          try{
                                int bufferReadResult = audioRecord.read(buffer,
0,frameSize);

                                if(bufferReadResult == 
AudioRecord.ERROR_INVALID_OPERATION)
                                        
if(log)Log.d(Tag,"record.read:ERROR_INVALID_OPERATION
returned");

                                else if(bufferReadResult == 
AudioRecord.ERROR_BAD_VALUE)
                                if(log)Log.d(Tag,"record.read:ERROR_BAD_VALUE
returned");

                                else if(bufferReadResult != frameSize)
                                        if(log)Log.d(Tag,"record.read:Requested 
" + frameSize +
                                                        " bytes but read" + 
bufferReadResult + "bytes");

                            else audioTrack.write(buffer,0,buffer.length);
                          }catch(Exception e)
                          {if(log)Log.e(Tag,"ERROR: " + e.toString());}
                        }

                        audioRecord.stop();
                        audioTrack.stop();
                        audioRecord.release();
                        audioTrack.release();
                }
            };//record_listener

            stop_listener = new OnClickListener()
            {
                @Override
                public void onClick(View arg0)
                {
                        isRecording = false;
                }
            };//stop_listener

           setListeners();
        }//onCreate

    private void initResourceRefs()//    {
        recordButton = (Button)findViewById(R.id.recordButton);
        stopButton = (Button)findViewById(R.id.stopButton);
    }//initResourceRefs()

    private void setListeners()
    {
        recordButton.setOnClickListener(record_listener);
        stopButton.setOnClickListener(stop_listener);
    }//setListeners

}//audioRecorderTest2

-- 

3. Android pattern for waiting on event

4. Two problems with SeekBars, one with ListViews, and one inside a PreferenceActivity

5. Should Plurals and Quantity Strings be used?

6. TextView resets its location after an animation

7. How to access internal storage on htc incredible