logo
down
shadow

Android http post with special character


Android http post with special character

By : user2949368
Date : November 17 2020, 01:00 AM
this will help First of all the variable i is out of scope inside of your listener, so you can't use it.
Second, remember that the click listener will be called after your for loop is complete, therefore using the variable i would be impossible (it no longer exists). However when you declare a final variable, it will be available inside the listener, at all times. You won't be able to change it's value though.
code :
for(int i=0;i<end;i++)
{   
    //bilder
    ImageView replace_img= new ImageView(this);
    replace_img.setImageResource(R.drawable.image_replace);
    RelativeLayout.LayoutParams tmp= new RelativeLayout.LayoutParams(250,250);
    newImg.add(replace_img);                
    ImageView v=  newImg.get(i);
    v.setId(i+1);

    // Set the final int that will be available in inner classes
    final int myInt = i;

    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View vi) {            
            vi.setOnClickListener(new View.OnClickListener() 
            { 
                @Override
                public void onClick(View v) 
                { 
                    // "myInt" is still usable here, however "i" is not
                    Intent o = new Intent(getBaseContext(), Edit_post2.class);
                    o.putExtra("POST_NR", myInt);
                    Post_list.this.startActivity(o); 
                }
            });
        }
    });
}


Share : facebook icon twitter icon
Special character on Http Request

Special character on Http Request


By : user2493012
Date : March 29 2020, 07:55 AM
it helps some times (Copy of)URL Contains Special characters
You can encode like this,
code :
public class URLUTF8Encoder
{   
 final static String[] hex = {
 "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
 "%08", "%09", "%0a", "%0b", "%0c", "%0d", "%0e", "%0f",
 "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
 "%18", "%19", "%1a", "%1b", "%1c", "%1d", "%1e", "%1f",
 "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27",
 "%28", "%29", "%2a", "%2b", "%2c", "%2d", "%2e", "%2f",
 "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37",
 "%38", "%39", "%3a", "%3b", "%3c", "%3d", "%3e", "%3f",
 "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47",
 "%48", "%49", "%4a", "%4b", "%4c", "%4d", "%4e", "%4f",
 "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57",
 "%58", "%59", "%5a", "%5b", "%5c", "%5d", "%5e", "%5f",
 "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67",
 "%68", "%69", "%6a", "%6b", "%6c", "%6d", "%6e", "%6f",
 "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77",
 "%78", "%79", "%7a", "%7b", "%7c", "%7d", "%7e", "%7f",
 "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87",
 "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f",
 "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97",
 "%98", "%99", "%9a", "%9b", "%9c", "%9d", "%9e", "%9f",
 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7",
 "%a8", "%a9", "%aa", "%ab", "%ac", "%ad", "%ae", "%af",
 "%b0", "%b1", "%b2", "%b3", "%b4", "%b5", "%b6", "%b7",
 "%b8", "%b9", "%ba", "%bb", "%bc", "%bd", "%be", "%bf",
 "%c0", "%c1", "%c2", "%c3", "%c4", "%c5", "%c6", "%c7",
 "%c8", "%c9", "%ca", "%cb", "%cc", "%cd", "%ce", "%cf",
 "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
 "%d8", "%d9", "%da", "%db", "%dc", "%dd", "%de", "%df",
 "%e0", "%e1", "%e2", "%e3", "%e4", "%e5", "%e6", "%e7",
 "%e8", "%e9", "%ea", "%eb", "%ec", "%ed", "%ee", "%ef",
 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
  "%f8", "%f9", "%fa", "%fb", "%fc", "%fd", "%fe", "%ff"
 };  
    public static String encode(String s)
    {
      StringBuffer sbuf = new StringBuffer();
      int len = s.length();
      for (int i = 0; i < len; i++) {
      int ch = s.charAt(i);
      if ('A' <= ch && ch <= 'Z') {     // 'A'..'Z'
       sbuf.append((char)ch);
      } else if ('a' <= ch && ch <= 'z') {  // 'a'..'z'
       sbuf.append((char)ch);
      } else if ('0' <= ch && ch <= '9') {  // '0'..'9'
       sbuf.append((char)ch);
      } else if (ch == ' ') {           // space
       sbuf.append('+');
    } else if (ch == '-' || ch == '_'     // unreserved
       || ch == '.' || ch == '!'
       || ch == '~' || ch == '*'
       || ch == '\'' || ch == '('
       || ch == ')') {
      sbuf.append((char)ch);
    } else if (ch <= 0x007f) {        // other ASCII
      sbuf.append(hex[ch]);
    } else if (ch <= 0x07FF) {        // non-ASCII <= 0x7FF
      sbuf.append(hex[0xc0 | (ch >> 6)]);
      sbuf.append(hex[0x80 | (ch & 0x3F)]);
     } else {                  // 0x7FF < ch <= 0xFFFF
       sbuf.append(hex[0xe0 | (ch >> 12)]);
       sbuf.append(hex[0x80 | ((ch >> 6) & 0x3F)]);
       sbuf.append(hex[0x80 | (ch & 0x3F)]);
    }
   }
    return sbuf.toString();
       }
     }      
Android default charset when sending http post/put - Problems with special characters

Android default charset when sending http post/put - Problems with special characters


By : user3145769
Date : March 29 2020, 07:55 AM
will help you Apparently, I forgot to set the StringEntity's charset to UTF-8. These lines did the trick:
code :
    httpPut.setEntity(new StringEntity(body, HTTP.UTF_8));
    httpPost.setEntity(new StringEntity(body, HTTP.UTF_8));
    final StringEntity se = new StringEntity(body, ContentType.APPLICATION_JSON);
    httpPut.setEntity(se);
Android http post with special character (utf-8?)

Android http post with special character (utf-8?)


By : user2853581
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I'll try to give you a sample code but it would be useful if you could write exactly where you have problems and what you don't understand. You will need an AsyncTask for the network operation. Try out the following:
code :
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        new AsyncConnection().execute();

    }

    // This is the code for async task.
    public class AsyncConnection extends AsyncTask<Void, Void, String> {

        @Override
        protected void onPostExecute(String result) {
            // you can use your result string here
        }

        @Override
        protected String doInBackground(Void... params) {
            StringBuffer response = new StringBuffer();
            try {
                // Create a new HTTP Client
                DefaultHttpClient defaultClient = new DefaultHttpClient();
                // Setup the get request
                HttpGet httpGetRequest = new HttpGet("URL");

                // Execute the request in the client
                HttpResponse httpResponse = defaultClient
                        .execute(httpGetRequest);

                BufferedReader in = new BufferedReader(new InputStreamReader(
                        httpResponse.getEntity().getContent()));
                String inputLine;

                while ((inputLine = in.readLine()) != null) {
                    response.append(inputLine);
                }
                in.close();
                Log.d("DEBUG", "response: " + response.toString());


            } catch (IOException e) {
                Log.d("DEBUG", "j " + response.toString());
                e.printStackTrace();
            }

            return response.toString();
        }

    }

}
How can i pass special character like "#", "^" in http.post url as parameters

How can i pass special character like "#", "^" in http.post url as parameters


By : sam
Date : March 29 2020, 07:55 AM
this one helps. You need to encode your params. You can encode them manually by using encodeURI or just add them into the param section on your request. In that way your params get serialized and encoded automatically.
code :
$http({
  url: 'requestFormDataInsert.jsp',
  method: 'POST',
  params: {
    manager: $scope.managerName,
    productName: $scope.productName,
    productVersion: $scope.versionNumber,
    expectedDate: $("#datepicker1").val(),
    description: $scope.description,
    requestType: $scope.requestType
  }
}).then(function (result) {
});
find a special character in file & remove the special character, before/after words of special character using shell

find a special character in file & remove the special character, before/after words of special character using shell


By : Kuang Yuan Lin
Date : March 29 2020, 07:55 AM
hope this fix your issue A file contains email addresses. Requirement is to remove words present before/after a special character & also the special character from a file. , I'd use perl or sed
Related Posts Related Posts :
  • Unable to add column dynamically into the sqlite table
  • android persistence activity which never stop
  • The Google Play services resources were not found. Check your project configuration to ensure that the resources are inc
  • How to select files from google drive in android?
  • Run a AsyncTask every 10 seconds until cancelled
  • Blur on touch. Android application
  • NDK Android - Can't build ARMv5 and V7 at the same time
  • Android development with Eclipse clean and build
  • How to set Different Key Background for every Key in Android Custom Keyboard
  • Face recognition using OpenCV in android?
  • Tumblr API - Jumblr for Android [OAuthConnectionException]
  • Small Icon on Notification not working correctly
  • ConstraintLayout match parent height on larger screens but scroll on smaller
  • Kotlin version issue
  • How can i make my android app look the same on RTL and LTR languages?
  • Can not detect Android NDK toolchain
  • Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only.
  • Facebook Key Hash for Play Store Release
  • backbutton confirm exit app android + phonegap + jquery
  • How to Make Instagram Listview in android?
  • Up and Down Enemy Movement using translate corona sdk
  • Set selection method is not working in gallery in android
  • How to implement onOptionsItemSelected for Sub-Menu Items?
  • HttpHostConnectException connection refused ConnectException ErrnoException
  • Adding Buttons to expendableListView as last Child
  • Android. Block phone on startup
  • How to programmatically check If string is not to wide to fit onto the screen in Android
  • EditText box cursor appear after touching box?
  • using if statement when video is done playing
  • Add to Aspectpath not found MonkeyTalk
  • GooglePlusUtil cannot be resolved (Android)
  • Trouble understanding Relative Layout
  • How to title/name each fragment separately to appear on PagerTitleStrip?
  • Android webView blinks
  • Available service types in WifiP2pDnsSdServiceInfo.newInstance
  • Hide only bottom action bar Android
  • Android + MoPub + PhoneGap (Cordova) Integration (Half working)
  • Android OnTouchListener results in jerky drags
  • android notification disappears after reboot
  • Optimising Canny Edge Detector for Android
  • How to Play the online streaming radio in Android
  • Blurry map tiles at start of android app based on google Maps API v2
  • How to combine java native within the XML android and dart Flutter
  • Intercept the outgoing call data, alter it & then write it back out- Why it is not possible?- Android
  • Bundle extra sends wrong string
  • Display a view using windowmanager on lock screen
  • is it possible to load images from the directory on web server?
  • android SDK manager, only show installed package
  • How to handle time zone difference between server and native android application?
  • ViewPager PagerAdapter delete items
  • How to solve different Preview/Picture sizes returned by android.hardware.camera?
  • How to get songs from album/Artist in android,using MediametadataRetriever?
  • Android UIAutomator how to tilt device
  • DialogFragment issues with screen orientation and MediaController
  • blank screen after re-starting launcher activity (failed binder transaction)
  • How to start activity Language and input
  • location-based Augmented Reality Framework (Android, iOS) with 3D Models?
  • android teamviewer intent with parameters
  • Picasso does not call onBitmapLoaded for the first time
  • How can I pass an audio file as input instead of recorded voice to Google search voice?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org