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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:25:11+00:00 2026-05-22T18:25:11+00:00

I am currently working on an SMS app which will be quite similar to

  • 0

I am currently working on an SMS app which will be quite similar to stock sms app.

But the problem is my app is loading much slower than the stock(inbuilt) app.

Here is my app’s code :-

public class ThreadData extends ListActivity
{
private static final Uri SMS_URI = Uri.parse("content://sms");
ArrayList<String> bodies = new ArrayList<String>();
MySMSAdapter adapter;
String name;

public void onCreate(Bundle bundle)
{
    super.onCreate(bundle);
    setContentView(R.layout.threadlist);
    Bundle extras = getIntent().getExtras();
    if(extras != null)
    {
        name = extras.getString("address");
    }
    Cursor cursor = getContentResolver().query(SMS_URI, null, null, null, "date ASC");
    startManagingCursor(cursor);
    while (cursor.moveToNext())
    {
        String Id = cursor.getString(cursor.getColumnIndex("_id"));
        String address = cursor.getString(cursor.getColumnIndex("address"));
        String body = cursor.getString(cursor.getColumnIndexOrThrow("body"));
        String personName = getPersonName(Id,  address);
        if(personName.equals(name))
        {
            bodies.add(body);
        }
    }
    //adapter = new MySMSAdapter(this, bodies);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.sms_inbox, R.id.row, bodies);
    ListView listView = getListView();
    listView.setAdapter(adapter);
}
public String getPersonName(String id, String address)
{
        if(id==null)
        {
            if(address != null)
            {
                return PhoneNumberUtils.formatNumber(address);
            }
            else
            {
                return null;
            }
        }

        Cursor c = this.getContentResolver().query(Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, address),
                   new String[] { ContactsContract.PhoneLookup.DISPLAY_NAME }, null, null, null);

        if(c != null)
        {
            try
            {
                if(c.getCount() > 0)
                {
                    c.moveToFirst();
                    return c.getString(0);
                }
            }
            finally
            {
                c.close();
            }
        }
        if(address != null)
        {
            return PhoneNumberUtils.formatNumber(address);
        }
        return null;
}

}

My custom adapter :-

public class MySMSAdapter extends BaseAdapter
{
private Activity activity;
private ArrayList<String> data;
LayoutInflater inflater;

public MySMSAdapter(Activity a, ArrayList<String> arrayList)
{
    activity = a;
    data = arrayList;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

public int getCount()
{
    return data.size();  //To change body of implemented methods use File | Settings | File Templates.
}

public Object getItem(int i)
{
    return data.get(i);  //To change body of implemented methods use File | Settings | File Templates.
}

public long getItemId(int i)
{
    return i;
}

public static class ViewHolder
{
    public TextView textView;
}

public View getView(final int i, View view, ViewGroup viewGroup)
{
    View row = view;
    final ViewHolder holder;
    if(view==null)
    {
        row = inflater.inflate(R.layout.sms_inbox, viewGroup, false);
        holder = new ViewHolder();
        holder.textView = (TextView)row.findViewById(R.id.row);
        row.setTag(holder);
    }
    else
    {
        holder = (ViewHolder)row.getTag();
    }

    holder.textView.setText(data.get(i));
    return row;
}
}

In my class i tried loading List with both the options(custom adapter as well as ArrayAdapter) But in both case my app is loading very slow. How to load it faster? I may prefer solution for my custom adapter as in future i may need few things to add in my layout like photos and other stuff.

Thanks. Please Help!!

  • 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-05-22T18:25:12+00:00Added an answer on May 22, 2026 at 6:25 pm

    You can use http://developer.android.com/guide/developing/tools/traceview.html profiler to localize performance issues. My guess the problem is you are doing disk operations (Cursor cursor = getContentResolver().query(…)) synchronously. Try to make this assync using AssyncTask i.e.

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

Sidebar

Related Questions

Im currently working on a timer app similar to apple's default Clock utility but
Im currently working on a site which will contain a products catalog. I am
I am working on an SMS receiver module in my app in which I
I'm currently working on an app that will tell students when their classes start
Currently working with Oracle, but will also need a solution for MS SQL. I
In my app i am sending multiple sms at one time which working perfectly
Currently working on a wp7 App, its quite basic. the user has a counter
Im currently working on an app which lists a set of objects in a
Currently working on something which uses ajax for some pagination. What I'm looking to
Currently, I am developing an App in which I have to send photo/video via

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.