Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Bundle;
import android.text.TextUtils;

public class Main {
    public static int getIntByString(Bundle bundle, String key, int def) {
        if (bundle == null)
            return def;
        String str = bundle.getString(key);
        if (!TextUtils.isEmpty(str)) {
            try {
                return Integer.parseInt(str);
            } catch (NumberFormatException e) {
                // TODO: handle exception
                e.printStackTrace();
            }
        }

        return def;
    }
}