Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;

import android.util.Log;

public class Main {
    public static String getResourceString(String recourceName, Activity context) {
        Class rStringClass = null;
        try {
            if (rStringClass == null) {
                rStringClass = Class.forName(
                        new StringBuilder().append(context.getPackageName()).append(".R$string").toString());
            }
            return context.getResources()
                    .getString(((Integer) rStringClass.getDeclaredField(recourceName).get(null)).intValue());
        } catch (Exception e) {
            Log.e(context.getPackageName(), e.getMessage(), e);
            context.finish();
        }
        return "";
    }
}