Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.database.Cursor;

import android.net.Uri;

import android.util.Log;

public class Main {
    public static String LOG_TAG = "SmsNoMore";

    public static String getSmsText(Context context, String msgId) {
        String result = null;
        try {
            Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"),
                    new String[] { "body", }, "_id = ?", new String[] { msgId, }, null);
            if (c.moveToFirst()) {
                result = c.getString(0);
            }
            c.close();
        } catch (Throwable t) {
            LOGE("getSmsText: " + t.getMessage());
            t.printStackTrace();
            result = null;
        }
        return result;
    }

    public static void LOGE(final String text) {
        Log.e(LOG_TAG, text);
    }
}