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 8811519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:23:08+00:00 2026-06-14T03:23:08+00:00

Here is my code where i am getting profile image bytes from twitter api,

  • 0

Here is my code where i am getting profile image bytes from twitter api,

new Thread() {

    public void run() {
        byte dbata[] = getBitmap(profle_pic_str);
        if (dbata != null) {
            EncodedImage bitmap_img = EncodedImage.createEncodedImage(dbata, 0, -1);
            Bitmap image =bitmap_img.getBitmap();
            final Bitmap profle_pic_bmp = image;
            final Bitmap scld_bmp = new Bitmap(90, 100);
            Application.getApplication().invokeLater(new Runnable() {
                public void run() {
                    if (profle_pic_bmp != null) {
                        profle_pic_bmp.scaleInto(scld_bmp, Bitmap.FILTER_LANCZOS);
                        phot_profle.setBitmap(scld_bmp);
                    } else {
                        Dialog.alert("null");
                    }
                }
            });
        // } else {
            // Dialog.alert("bytes are null");
        }
    }
}.start(); 

Here i have method getBitmap(profle_pic_str); which returning bytes array of image,

public byte[] getBitmap(String url) {
    Bitmap bitmap = null;
    String strg = HttpConnector.getConnectionString();
    byte b[] = null;
    try {
        b = getXML(url + strg);
    } catch (IOException ie) {
        ie.printStackTrace();
    }
    return b;
} 

the url which i used is this one

http://api.twitter.com/1/users/profile_image?screen_name=screen_nameof_user&size=bigger

public byte[] getXML(String url) throws IOException {
    ContentConnection connection = 
        (ContentConnection) javax.microedition.io.Connector.open(url);
    java.io.DataInputStream iStrm = connection.openDataInputStream();
    java.io.ByteArrayOutputStream bStrm = null;
    byte xmlData[] = null;
    try {
        // ContentConnection includes a length method
        int length = (int) connection.getLength();
        if (length != -1) {
            xmlData = new byte[length];
            // Read the png into an array
            // iStrm.read(imageData);
            iStrm.readFully(xmlData);
        } else // Length not available...
        {
            bStrm = new java.io.ByteArrayOutputStream();
            int ch;
            while ((ch = iStrm.read()) != -1) bStrm.write(ch);
            xmlData = bStrm.toByteArray();
            bStrm.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // Clean up
        if (iStrm != null) iStrm.close();
        if (connection != null) connection.close();
        if (bStrm != null) bStrm.close();
    }
    return xmlData;
} 

When i am trying to convert byte array to EncodedImage

EncodedImage  bitmap_img = EncodedImage.createEncodedImage(dbata, 0, -1);

in this line of code i am getting illegal argument exception.

same code is working for Facebook profile image. I dont know why this code giving error when i am doing for twitter. Please help me friends.

  • 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-14T03:23:10+00:00Added an answer on June 14, 2026 at 3:23 am

    try this –

    EncodedImage _encoded_img = EncodedImage.createEncodedImage(dbata, 0, dbata.length);
    

    On your code,

    EncodedImage bitmap_img = EncodedImage.createEncodedImage(dbata, 0,-1);
    

    -1 is the length of the array. Its not static. Change -1 to dbata.length.

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

Sidebar

Related Questions

I'm getting an NSMenuItem from the Main Menu , with the code here :
Here is my code: Blob rgbBlob; ifstream LoadFile; Image profile_test(sRGB.icc); profile_test.write(&rgbBlob); jpg_src.profile(ICC,rgbBlob); I'm trying
Ok, guys, here's my code for getting SMS: Cursor cursor = getContentResolver().query(Uri.parse(uri), null, CallLog.Calls.DATE
See here for code: http://jsfiddle.net/ecFBK/10/ I'm having a hard time getting this to work
I am getting leak at [pool release]; My code here is: #pragma mark UISearchBarDelegate
I am getting this error here is my code if(isset($_POST['submit'])) { $projTit=mysql_escape_string($_POST['projecttitle']); $projCat=mysql_escape_string($_POST['projectcategory']); $budget=intval(mysql_escape_string($_POST['budget']));
Hi here is the code in question and the issues that i am getting,
I'm getting syntax error in firebug here is the code : $('#moderator-attention').live('toogle', function(){ function
I keep getting this error while trying to modify some tables. Here's my code:
I am getting this warning even though everything functions perfectly. Here is the code

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.