Skip to content

Instantly share code, notes, and snippets.

View ParryPatel021's full-sized avatar
🛠️
Working

Parth Patel ParryPatel021

🛠️
Working
View GitHub Profile
@nikartm
nikartm / Cache.java
Last active April 26, 2024 07:40
Android. Example how to save an image file in the App cache and get Uri for it. The Image will not be saved in a device gallery, only in an internal App cache.
package com.github.example;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
@JCarlosR
JCarlosR / PreferenceHelper.kt
Last active December 25, 2023 08:20 — forked from krupalshah/PreferenceHelper.kt
Helper for shared preferences management - Kotlin version
package com.programacionymas.helpers
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
object PreferenceHelper {
fun defaultPrefs(context: Context): SharedPreferences
= PreferenceManager.getDefaultSharedPreferences(context)
@hamakn
hamakn / height.java
Created April 6, 2015 02:41
Android: Get height of status, action, navigation bar (pixels)
// status bar height
int statusBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
// action bar height
int actionBarHeight = 0;
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(