Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.database.Cursor;

import android.net.Uri;

public class Main {
    public static final Uri MMS_CONTENT_URI = Uri.parse("content://mms");

    public static String getMmsAddress(Context context, long messageId) {
        final String[] projection = new String[] { "address", "contact_id", "charset", "type" };
        final String selection = "type=137"; // "type="+ PduHeaders.FROM,

        Uri.Builder builder = MMS_CONTENT_URI.buildUpon();
        builder.appendPath(String.valueOf(messageId)).appendPath("addr");

        Cursor cursor = context.getContentResolver().query(builder.build(), projection, selection, null, null);

        if (cursor != null) {
            try {
                if (cursor.moveToFirst()) {
                    return cursor.getString(0);
                }
            } finally {
                cursor.close();
            }
        }

        return context.getString(android.R.string.unknownName);
    }
}