Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:46:21+00:00 2026-06-06T19:46:21+00:00

Initially my activity calls new DropboxApi(token).execute(); with token. public class DropboxApi extends AsyncTask<Void, Long,

  • 0

Initially my activity calls new DropboxApi(token).execute(); with token.

public class DropboxApi extends AsyncTask<Void, Long, Boolean> {
    public String token;
    public DropboxApi(String a) {
        // TODO Auto-generated constructor stub
        token=a;
    }
    String HMAC_SHA1_ALGORITHM = "HmacSHA1";
    public String Sign(String token)// throws Exception
    {
        String uri = "https://api.dropbox.com/1/account/info";
        //Uri json = GetResponse(uri);
        //return ParseJson<Account>(json);
        uri+="?";
        String queryParams = "oauth_consumer_key=2f2y1dyuqhp58ek&oauth_token="+token+"&oauth_nonce=6880853&oauth_timestamp=";

         java.util.Date date= new java.util.Date();
         //System.out.println(new Timestamp(date.getTime()));

         queryParams+=(new Timestamp(date.getTime()).toString())+"&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=";

         uri+=queryParams;
         Mac mac=null;
        try {
            mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
        } catch (NoSuchAlgorithmException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
         Key key=new SecretKeySpec("2f2y1dyuqhp58ek".getBytes(), HMAC_SHA1_ALGORITHM) ;
         try {
            mac.init(key);
        } catch (InvalidKeyException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
         byte[] rawHmac = mac.doFinal(queryParams.getBytes());
         String result=new String(Base64.encode(rawHmac,Base64.DEFAULT));
         uri+=result;
         return uri;


    }

    @Override
    protected Boolean doInBackground(Void... params) {
        // TODO Auto-generated method stub


            HttpClient httpclient = new DefaultHttpClient();   
            HttpPost httpPost = new HttpPost(Sign(token));
            int k=0;
            k=23;
            HttpResponse response;
            try {
                int j=3;
                j=0;
                response = httpclient.execute(httpPost); // the request executes
                Log.d("HTTP","Executed");
        String  responseBody = EntityUtils.toString(response.getEntity());

            } catch (ClientProtocolException e) {
                e.printStackTrace();
            }
            catch(ConnectTimeoutException e){
            e.printStackTrace();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            //return null;

        return null;
    }


}

In debug,Code works fine until it returns uri..which is:

https://api.dropbox.com/1/account/info?oauth_consumer_key=2f2y1dyuqhp58ek&oauth_token=wz27t6thob0fbxl&oauth_nonce=6880853&amp; oauth_timestamp=2012-06-24 23:46:51.734&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=s8zaFHmQJ24BTxTYV4VUSLdV9d8=

This is my first time making an http request..is this code supposed to work?

06-24 23:44:47.364: E/AndroidRuntime(11315):    at dalvik.system.NativeStart.main(Native Method)
06-24 23:44:53.033: I/Process(11315): Sending signal. PID: 11315 SIG: 9
06-24 23:45:43.404: W/ActivityThread(11375): Application cloud.mobile is waiting for the debugger on port 8100...
06-24 23:45:43.563: I/System.out(11375): Sending WAIT chunk
06-24 23:45:43.683: I/dalvikvm(11375): Debugger is active
06-24 23:45:43.846: I/System.out(11375): Debugger has connected
06-24 23:45:43.887: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:44.087: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:44.338: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:44.544: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:44.773: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:44.983: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:45.183: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:45.393: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:45.594: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:45.805: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:46.004: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:46.214: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:46.414: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:46.627: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:46.833: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:47.034: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:47.254: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:47.466: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:47.663: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:47.873: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:48.073: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:48.283: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:48.483: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:48.684: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:48.894: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:49.094: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:49.295: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:49.504: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:49.714: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:49.915: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:50.123: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:50.323: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:50.524: I/System.out(11375): waiting for debugger to settle...
06-24 23:45:50.754: I/System.out(11375): debugger has settled (1426)
06-24 23:45:53.493: D/dalvikvm(11375): GC_EXTERNAL_ALLOC freed 721 objects / 53976 bytes in 321ms
06-24 23:48:29.164: D/AndroidRuntime(11375): Shutting down VM
06-24 23:48:29.164: W/dalvikvm(11375): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-24 23:48:29.423: E/AndroidRuntime(11375): FATAL EXCEPTION: main
06-24 23:48:29.423: E/AndroidRuntime(11375): java.lang.IllegalArgumentException: Illegal character in query at index 122: https://api.dropbox.com/1/account/info?oauth_consumer_key=2f2y1dyuqhp58ek&oauth_token=wz27t6thob0fbxl&oauth_nonce=6880853& oauth_timestamp=2012-06-24 23:46:51.734&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=s8zaFHmQJ24BTxTYV4VUSLdV9d8=
06-24 23:48:29.423: E/AndroidRuntime(11375):    at java.net.URI.create(URI.java:970)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at org.apache.http.client.methods.HttpPost.<init>(HttpPost.java:79)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at cloud.mobile.DropboxApi.httpMethod(DropboxApi.java:67)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at cloud.mobile.MCActivity$3.onClick(MCActivity.java:161)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at android.view.View.performClick(View.java:2408)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at android.view.View$PerformClick.run(View.java:8816)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at android.os.Handler.handleCallback(Handler.java:587)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at android.os.Looper.loop(Looper.java:123)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at android.app.ActivityThread.main(ActivityThread.java:4627)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at java.lang.reflect.Method.invokeNative(Native Method)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at java.lang.reflect.Method.invoke(Method.java:521)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-24 23:48:29.423: E/AndroidRuntime(11375):    at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:46:23+00:00Added an answer on June 6, 2026 at 7:46 pm

    It’s because you are trying to perform a network access on the UI thread. You should never perform potentially expensive operations (network accesses, file I/O, remote database connections, database transactions, etc.) on the this thread, as it might block the UI thread and prevent your layout from inflating/responding to touch events. You need to wrap your HTTP Request in an AsyncTask (recommended) or Thread instead.

    Read my blog post on the subject:

    Why Ice Cream Sandwich Crashes Your App


    Also, there is a space in the url (lol)… that’s why you are getting an IllegalArgumentException on character 122. Remove the space from ... 6880853& oauth_timestamp=2012 ...

    The stuff I wrote above still applies. Please, please, please don’t perform this task on the UI thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have appwidgetprovider class as below which calls an activity to open for (int
I have a tab activity, and inside one tab I have activitygroup. Initially activity
I'm trying to use static variables on a public class for passing them between
I initially create my fragments inside the Activity onCreate(). Than I go about creating
Initially I am having a simple ListView Activity that consists of few formulae and
An activity has a Button and a ListView. Initially, only the Button is visible.
Very strange thing here. I initially had an activity that was the start up
I have an activity with the following layout. So in this screen, initally the
Initially I thought it was a CSS issue but I built a small sample
Initially I used DIN font for text. Later I come to know it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.