SkillAgentSearch skills...

AndroidBaseUtils

Context free and basic utils to build Android project conveniently

Install / Use

/learn @TheFinestArtist/AndroidBaseUtils
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

AndroidBaseUtils

Platform API License

AndroidBaseUtils Art Image

Context free and basic utils to build Android project conveniently

Any kinds of contributions including pull requests, registering new issues, sending me personal emails are always welcome. Let me know if you have any idea about basic utils for Android development.

Table of Contents

  1. Get started
  2. Utils
    1. Base
    2. LogUtil (L)
    3. LogHelper
    4. ContextUtil (Ctx)
    5. ResourcesUtil (Res)
    6. PreferencesUtil (Pref)
    7. ExtrasBinder
    8. UnitConverter (Unit)
    9. KeyboardUtil (Keyboard)
    10. APILevel
    11. DisplayUtil
    12. ViewUtil
    13. ServiceUtil
    14. ThemeUtil
    15. ActivityBuilder
    16. BundleBuilder
    17. PackageUtil
    18. VibratorUtil
    19. ClipboardManagerUtil
    20. TypedValueUtil
    21. WindowManagerUtil
    22. IntArrayUtil
    23. SparseArrayUtil
    24. ThreadUtil
  3. Contributors
  4. License

Get started

Gradle Dependency (jcenter)

Release is in process...

buildscript {
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apply plugin: 'com.neenbedankt.android-apt'

dependencies {
    compile 'com.thefinestartist:utils:0.9.5'
    apt 'com.thefinestartist:compilers:0.9.5'
}

Initialization (Application)

Call Base.initialize(context) within your Application onCreate() method.

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Base.initialize(this);
    }
}

Utils

Base

Base helps to get Context, Resources, Assets, Configuration and DisplayMetrics in any class.

void            Base.initialize(Context context);

Context         Base.getContext();
Resources       Base.getResources();
Theme           Base.getTheme();
AssetManager    Base.getAssets();
Configuration   Base.getConfiguration();
DisplayMetrics  Base.getDisplayMetrics();

LogUtil (L)

LogUtil helps to deal with Log conveniently.
L is abbreviation class of LogUtil. You can extends LogUtil to create your own L.

Settings    L.getDefaultSettings();

LogHelper   L.tag(String tag);
LogHelper   L.tag(@StringRes int tagRes);
LogHelper   L.tag(Class clazz);
LogHelper   L.showThreadInfo(boolean showThreadInfo);
LogHelper   L.stackTraceCount(int stackTraceCount);
LogHelper   L.logLevel(LogLevel logLevel);
LogHelper   L.showDivider(boolean showDivider);
LogHelper   L.logPrinter(LogPrinter logPrinter);

void        L.v(byte message);
void        L.v(char message);
void        L.v(short message);
void        L.v(int message);
void        L.v(long message);
void        L.v(float message);
void        L.v(double message);
void        L.v(boolean message);
void        L.v(String message);
void        L.v(JSONObject message);
void        L.v(JSONArray message);
void        L.v(Exception message);
void        L.v(Object message);
// and so on...

void        L.json(String jsonString);
void        L.json(LogLevel logLevel, String jsonString);
void        L.xml(String xmlString);
void        L.xml(LogLevel logLevel, String jsonString);
// Set default settings at your Application.
L.getDefaultSettings()
        .setTag(LogUtil.class)
        .setShowThreadInfo(false)
        .setStackTraceCount(0)
        .setLogLevel(LogLevel.FULL)
        .setShowDivider(false)
        .setLogPrinter(new AndroidLogPrinter());
        
L.v("Hello World");
L.tag("Tag").e(12.0f);
L.showThreadInfo(true).i(new int[]{1, 2, 3});
L.stackTraceCount(3).showDivider(true).json("{\"name\":\"Leonardo Taehwan Kim\",\"email\":\"leonardo@thefinestartist.com\"}");

LogUtil Sample

LogHelper

LogHelper helps to deal with Log conveniently.

LogHelper   new LogHelper();
LogHelper   new LogHelper(String tag);
LogHelper   new LogHelper(@StringRes int tagRes);
LogHelper   new LogHelper(Class clazz);

LogHelper   tag(String tag);
LogHelper   tag(@StringRes int tagRes);
LogHelper   tag(Class clazz);
LogHelper   showThreadInfo(boolean showThreadInfo);
LogHelper   stackTraceCount(int stackTraceCount);
LogHelper   logLevel(LogLevel logLevel);
LogHelper   showDivider(boolean showDivider);
LogHelper   logPrinter(LogPrinter logPrinter);

void        v(byte message);
void        v(char message);
void        v(short message);
void        v(int message);
void        v(long message);
void        v(float message);
void        v(double message);
void        v(boolean message);
void        v(String message);
void        v(JSONObject message);
void        v(JSONArray message);
void        v(Exception message);
void        v(Object message);
// and so on...

void        json(String jsonString);
void        json(LogLevel logLevel, String jsonString);
void        xml(String xmlString);
void        xml(LogLevel logLevel, String jsonString);
// Set default settings at any Class.
LogHelper logHelper = new LogHelper(MainActivity.class).showThreadInfo(true);

logHelper.v("Hello World");
logHelper.e(12.0f);
logHelper.json("{\"name\":\"Leonardo Taehwan Kim\",\"email\":\"leonardo@thefinestartist.com\"}");

LogHelper Sample

ContextUtil (Ctx)

ContextUtil helps to use Context conveniently.
Ctx is abbreviation class of ContextUtil. You can extends ContextUtil to create your own Ctx.

boolean         Ctx.bindService(Intent service, ServiceConnection conn, int flags);
int             Ctx.checkCallingOrSelfPermission(String permission);
int             Ctx.checkSelfPermission(@NonNull String permission);
void            Ctx.enforceCallingOrSelfPermission(String permission, String message);
void            Ctx.enforceCallingOrSelfUriPermission(Uri uri, int modeFlags, String message);
ApplicationInfo Ctx.getApplicationInfo();
File            Ctx.getCacheDir();
File            Ctx.getExternalCacheDir();
File            Ctx.getExternalFilesDir(String type);
Looper          Ctx.getMainLooper();
Object          Ctx.getSystemService(String name);
void            Ctx.sendBroadcast(Intent intent, String receiverPermission);
void            Ctx.sendBroadcast(Intent intent);
boolean         Ctx.startActivities(Intent[] intents, Bundle options);
boolean         Ctx.startActivities(Intent[] intents);
void            Ctx.startActivity(@NonNull Intent intent);
void            Ctx.startActivity(Intent intent, Bundle options);
ComponentName   Ctx.startService(Intent service);
boolean         Ctx.stopService(Intent service);
void            Ctx.unbindService(ServiceConnection conn);
// and so on...

ResourcesUtil (Res)

ResourcesUtil helps to use Resources conveniently.
Res is abbreviation class of ResourcesUtil. You can extends ResourcesUtil to create your own Res.

XmlResourceParser   Res.getAnimation(@AnimRes int animRes);
boolean             Res.getBoolean(@BoolRes int boolRes);
int                 Res.getColor(@ColorRes int colorRes);
int                 Res.getColor(@ColorRes int colorRes, Resources.Theme theme);
ColorStateList      Res.getColorStateList(@ColorRes int colorRes);
ColorStateList      Res.getColorStateList(@ColorRes int colorRes, Resources.Theme theme);
float               Res.getDimension(@DimenRes int dimenRes);
int                 Res.getDimensionPixelOffset(@DimenRes int dimenRes);
int                 Res.getDimensionPixelSize(@DimenRes int dimenRes);
DisplayMetrics      Res.getDisplayMetrics();
Drawable            Res.getDrawable(@DrawableRes int drawableRes);
int                 Res.getIdentifier(String name, String defType, String defPackage);
int[]               Res.getIntArray(@ArrayRes int arrayRes);
int                 Res.getInteger(@IntegerRes int integerRes);
XmlResourceParser   Res.getLayout(@LayoutRes int layoutRes);
String              Res.getQuantityString(int id, int quantity, Object... formatArgs);
CharSequence        Res.getQuantityText(int id, int quantity);
String              Res.getResourceEntryName(@AnyRes int anyRes);
String              Res.getResourceName(@AnyRes int anyRes);
String              Res.getResourcePackageName(@AnyRes int anyRes);
String              Res.getResourceTypeName(@AnyRes int anyRes);
String              Res.getString(@StringRes int stringRes);
String              Res.getString(@StringRes int stringRes, Object... formatArgs);
String[]            Res.getStringArray(@ArrayRes int arrayRes);
CharSequence        Res.getText(@StringRes int stringRes, CharSequence def);
CharSequence        Res.getText(@StringRes int stringRes);
CharSequence[]      Res.getTextArray(@ArrayRes int arrayRes);
void                Res.getValue(String name, TypedValue outValue, boolean resolveRefs);
void                Res.getValue(@AnyRes int anyRes, TypedValue outValue, boolean resolveRefs);
void                Res.getValueForDensity(@AnyRes int anyRes, int density, TypedValue outValue, boolean resolveRefs);
XmlResourceParser   Res.getXml(@XmlRes int xmlRes);
TypedArray          Res.obtainAttributes(AttributeSet set, int[] attrs);
TypedArray          Res.obtainTypedArray(@ArrayRes int anyRes);
InputStream         Res.openRawResource(@R

Related Skills

View on GitHub
GitHub Stars661
CategoryDevelopment
Updated1d ago
Forks107

Languages

Java

Security Score

80/100

Audited on Mar 30, 2026

No findings