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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:29:56+00:00 2026-06-01T19:29:56+00:00

I’ve to develop an android application and one of its activity is: Detecting New

  • 0

I’ve to develop an android application and one of its activity is:

  1. Detecting New MMS messages
  2. Get Sender number to check if it is the number i want to receive from it in my application
  3. Getting (txt + image) from MMS
  4. Showing (Txt + Image) data in ListView

well, I found a code that might help me in the 2nd and 3rd tasks
but i tried it and test it on my mobile and it is work but it did not retrieve anything just black interface!!!

Maybe the problem that i didn’t understand some part of this code,

I wrote my comment above each statement that I couldn’t understand it please answer my comments that inside the code and help me to understand what i am missing
hope to get ur responses early. and please be clear.

   import java.io.BufferedReader;
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.InputStreamReader;
   import java.text.MessageFormat;

   import android.app.Activity;
   import android.content.ContentResolver;
   import android.content.ContentValues;
   import android.content.Context;
   import android.database.Cursor;
   import android.graphics.Bitmap;
   import android.graphics.BitmapFactory;
   import android.net.Uri;
   import android.os.Bundle;
   import android.telephony.SmsMessage;
   import android.view.LayoutInflater;
   import android.view.View;
   import android.view.ViewGroup;
   import android.widget.ImageView;
   import android.widget.ListView;
   import android.widget.TextView;
     import android.app.Activity;
     import android.os.Bundle;

   public class MMSReceiverActivity extends Activity {

  private final Uri CONTENT_URI_PART = Uri.parse("content://mms/part");
   private static final String MSG_ID_STR = "mid=%1$s"; // I don't understand it

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Start Copying Code
    // I don't know how can I retrieve mms id
    long msg_id = this.getIntent().getLongExtra("msg_id", 0);
    // What's different between ViewGroup and ListView
    ViewGroup listview = (ViewGroup) findViewById(R.id.mmsdetaillist);
    // What's different between "content://mms/part" and "content://mms/"
    Cursor cursor = getContentResolver().query(CONTENT_URI_PART, null,
            String.format(MSG_ID_STR, msg_id), null, null);

    if (cursor.moveToFirst()) {
        do {
            // Why he puts partID
            String partId = cursor.getString(cursor.getColumnIndex("_id"));
            String type = cursor.getString(cursor.getColumnIndex("ct"));

            if ("text/plain".equals(type)) {
                String data = cursor.getString(cursor
                        .getColumnIndex("_data"));
                String body;
                // What's the different between if it's null or not all of
                // them will return (text)
                if (data != null) {
                    // implementation of this method below
                    body = getMmsText(partId);
                } else {
                    body = cursor.getString(cursor.getColumnIndex("text"));
                }

                // Why he declared it like this i mean why it didn't declare
                // like this findViewById (R.) etc
                TextView t = new TextView(this);
                t.setText(body);
                listview.addView(t);

                // Why here else ?? it should be only if because if MMS
                // contains Text + img : so it'll ignore the (else = img)
                // part !

            } else if ("image/jpeg".equals(type)
                    || "image/bmp".equals(type) || "image/gif".equals(type)
                    || "image/jpg".equals(type) || "image/png".equals(type)) {
                Bitmap bitmap = getMmsImage(partId);
                ImageView iv = new ImageView(this);
                iv.setImageBitmap(bitmap);
                listview.addView(iv);
            }
        } while (cursor.moveToNext());
    }
    cursor.close();

}

public String getMmsText(String id) {
    Uri partURI = Uri.parse("content://mms/part/" + id);
    InputStream is = null;
    StringBuilder sb = new StringBuilder();
    try {
        is = getContentResolver().openInputStream(partURI);
        if (is != null) {
            InputStreamReader isr = new InputStreamReader(is, "UTF-8");
            BufferedReader reader = new BufferedReader(isr);
            String temp = reader.readLine();
            while (temp != null) {
                sb.append(temp);
                temp = reader.readLine();
            }
        }
    } catch (IOException e) {
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
            }
        }
    }
    return sb.toString();
}

public Bitmap getMmsImage(String _id) {
    Uri partURI = Uri.parse("content://mms/part/" + _id);
    InputStream is = null;
    Bitmap bitmap = null;
    try {
        is = getContentResolver().openInputStream(partURI);
        bitmap = BitmapFactory.decodeStream(is);
    } catch (IOException e) {
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
            }
        }
    }
    return bitmap;
}
 }

Note: everyTime i search on sending or receiving MMS i got this link , But until now i do not get it

Should i use repo and Git?
and what is repo and Git?
why should i use in MMS?

should i use it when send and receive MMS? if yes for why?
can i use this code

 content://mms-sms/conversations

instead of repo and git?

repo and Git

  • 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-01T19:29:57+00:00Added an answer on June 1, 2026 at 7:29 pm

    Most of your questions have nothing to do with the MMS part of your assignment. Most of it is standard java and/or Android, that you need to understand before taking on such a task.

    Besides that, SMS and MMS are not directly supported and is mostly undocumentet, so it is very hard to work with.

    I have been playing around with sms and mms and found these links very useful:

    How to Read MMS Data in Android?

    http://groups.google.com/group/android-developers/browse_thread/thread/d0c15ec17c12af0e?fwc=1&pli=1

    And now that i’m at it, i might as well answer some of the more simple questions you have:

    “ViewGroup and ListView”

    A ViewGroup is a superclass for most views that can contain other views (LinearLayout, RelativeLayout …), where a ListView is “a ViewGorup that creates a list of scrollable items.”

    “Why he declared it like this i mean why it didn’t declare like this findViewById (R.) etc”

    findViewById is used when you have an xml layout file, and want to reference a View in that layout. In this case he creates a TextView at runtime (Instead of defining it in an xml file) and adds it to the ListView.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
Thanks in advance for your help. I have a need within an application to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.