本文整理了Java中com.blankj.utilcode.util.Utils
类的一些代码示例,展示了Utils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils
类的具体详情如下:
包路径:com.blankj.utilcode.util.Utils
类名称:Utils
[英]```
author: Blankj
blog : http://blankj.com
time : 16/12/08
desc : Utils初始化相关
[中]```
author: Blankj
blog : http://blankj.com
time : 16/12/08
desc : Utils初始化相关
代码示例来源:origin: zyyoona7/EasyPopup
@Override
public void onCreate() {
super.onCreate();
// init it in the function of onCreate in ur Application
Utils.init(this);
}
}
代码示例来源:origin: hoangkien0705/Android-UtilCode
/**
* 获取App包名
*
* @return App包名
*/
public static String getAppPackageName() {
return Utils.getContext().getPackageName();
}
代码示例来源:origin: ZhuoKeTeam/QPM
/**
* 复制文本到剪贴板
*
* @param text 文本
*/
public static void copyText(final CharSequence text) {
ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
//noinspection ConstantConditions
cm.setPrimaryClip(ClipData.newPlainText("text", text));
}
代码示例来源:origin: ZhuoKeTeam/QPM
/**
* 复制uri到剪贴板
*
* @param uri uri
*/
public static void copyUri(final Uri uri) {
ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
//noinspection ConstantConditions
cm.setPrimaryClip(ClipData.newUri(Utils.getApp().getContentResolver(), "uri", uri));
}
代码示例来源:origin: sdwfqin/AndroidSamples
@Override
public void onCreate() {
super.onCreate();
Utils.init(this);
}
}
代码示例来源:origin: hoangkien0705/Android-UtilCode
/**
* 启动服务
*
* @param cls 服务类
*/
public static void startService(Class<?> cls) {
Intent intent = new Intent(Utils.getContext(), cls);
Utils.getContext().startService(intent);
}
代码示例来源:origin: ZhuoKeTeam/QPM
/**
* 复制意图到剪贴板
*
* @param intent 意图
*/
public static void copyIntent(final Intent intent) {
ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
//noinspection ConstantConditions
cm.setPrimaryClip(ClipData.newIntent("intent", intent));
}
代码示例来源:origin: firelotus/Meteorite
@Override
public void onCreate() {
super.onCreate();
mContext = this;
mHandler = new Handler();
//AppStatusTracker.init(this);
Utils.init(this);
exceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(handler);
}
}
代码示例来源:origin: hoangkien0705/Android-UtilCode
/**
* px转sp
*
* @param pxValue px值
* @return sp值
*/
public static int px2sp( float pxValue) {
final float fontScale = Utils.getContext().getResources().getDisplayMetrics().scaledDensity;
return (int) (pxValue / fontScale + 0.5f);
}
代码示例来源:origin: ZhuoKeTeam/QPM
@SuppressLint("MissingPermission")
private static String getOCCID() {
TelephonyManager tm =
(TelephonyManager) Utils.getApp().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getSimSerialNumber() : null;
}
代码示例来源:origin: fangxiaogang/WanAndroidxg
@Override
public void onCreate() {
super.onCreate();
myApplication = this;
initApplicationComponent();
// CrashReport.initCrashReport(getApplicationContext(), "53b6bf0d48", false);
Utils.init(this);
}
代码示例来源:origin: hoangkien0705/Android-UtilCode
/**
* px转dp
*
* @param pxValue px值
* @return dp值
*/
public static int px2dp(float pxValue) {
final float scale = Utils.getContext().getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
代码示例来源:origin: yangchong211/YCAudioPlayer
@Override
public void onExecuteFail(Exception e) {
ToastUtils.showRoundRectToast(Utils.getApp().getResources().getString(R.string.unable_to_play));
}
}.execute();
代码示例来源:origin: sdwfqin/AndroidSamples
@Override
public void onCreate() {
instance = this;
super.onCreate();
Utils.init(this);
initLog();
}
代码示例来源:origin: hoangkien0705/Android-UtilCode
/**
* 判断是否横屏
*
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isLandscape() {
return Utils.getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
代码示例来源:origin: yangchong211/YCAudioPlayer
public static String getFileName(String artist, String title) {
artist = stringFilter(artist);
title = stringFilter(title);
if (TextUtils.isEmpty(artist)) {
artist = Utils.getApp().getString(R.string.unknown);
}
if (TextUtils.isEmpty(title)) {
title = Utils.getApp().getString(R.string.unknown);
}
return artist + " - " + title;
}
代码示例来源:origin: Deemonser/AndroidSerialPort
@Override
public void onCreate() {
super.onCreate();
Utils.init(this);
JodaTimeAndroid.init(this);
}
}
代码示例来源:origin: hoangkien0705/Android-UtilCode
public Builder() {
if (defaultDir != null) return;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
&& Utils.getContext().getExternalCacheDir() != null)
defaultDir = Utils.getContext().getExternalCacheDir() + FILE_SEP + "log" + FILE_SEP;
else {
defaultDir = Utils.getContext().getCacheDir() + FILE_SEP + "log" + FILE_SEP;
}
}
代码示例来源:origin: yangchong211/YCAudioPlayer
/**
* 从媒体库加载封面<br>
* 本地音乐
*/
private Bitmap loadCoverFromMediaStore(long albumId) {
ContentResolver resolver = Utils.getApp().getContentResolver();
Uri uri = FileMusicUtils.getMediaStoreAlbumCoverUri(albumId);
InputStream is;
try {
is = resolver.openInputStream(uri);
} catch (FileNotFoundException ignored) {
return null;
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
return BitmapFactory.decodeStream(is, null, options);
}
代码示例来源:origin: hoangkien0705/Android-UtilCode
public static void init() {
Utils.init(RuntimeEnvironment.application);
}
内容来源于网络,如有侵权,请联系作者删除!