本文整理了Java中com.blankj.utilcode.util.Utils.getApp()
方法的一些代码示例,展示了Utils.getApp()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getApp()
方法的具体详情如下:
包路径:com.blankj.utilcode.util.Utils
类名称:Utils
方法名:getApp
暂无
代码示例来源: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: 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: 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: ZhuoKeTeam/QPM
@SuppressLint("MissingPermission")
private static String getOCCID() {
TelephonyManager tm =
(TelephonyManager) Utils.getApp().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getSimSerialNumber() : null;
}
代码示例来源:origin: yangchong211/YCAudioPlayer
@Override
public void onExecuteFail(Exception e) {
ToastUtils.showRoundRectToast(Utils.getApp().getResources().getString(R.string.unable_to_play));
}
}.execute();
代码示例来源: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: yangchong211/YCAudioPlayer
/**
* 获取默认的bitmap视图
* @param type 类型
* @return bitmap对象
*/
private Bitmap getDefaultCover(Type type) {
switch (type) {
case BLUR:
return BitmapFactory.decodeResource(Utils.getApp().getResources(), R.drawable.default_cover);
case ROUND:
Bitmap bitmap = BitmapFactory.decodeResource(Utils.getApp().getResources(), R.drawable.default_cover);
bitmap = ImageUtils.resizeImage(bitmap, ScreenUtils.getScreenWidth() / 2, ScreenUtils.getScreenWidth() / 2);
return bitmap;
default:
return BitmapFactory.decodeResource(Utils.getApp().getResources(), R.drawable.default_cover);
}
}
代码示例来源:origin: ZhuoKeTeam/QPM
/**
* 获取剪贴板的文本
*
* @return 剪贴板的文本
*/
public static CharSequence getText() {
ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
//noinspection ConstantConditions
ClipData clip = cm.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
return clip.getItemAt(0).coerceToText(Utils.getApp());
}
return null;
}
代码示例来源:origin: Deemonser/AndroidSerialPort
private LeftHeadBean getLeftBaudRateBean() {
ArrayList<LeftDetailBean> list = new ArrayList<>();
int[] array = Utils.getApp().getResources().getIntArray(R.array.baud_rate);
for (int i : array) {
if (i == mBaudRate) {
list.add(new LeftDetailBean(String.valueOf(i), true));
} else {
list.add(new LeftDetailBean(String.valueOf(i)));
}
}
LeftHeadBean bean = new LeftHeadBean();
bean.imageRes = R.mipmap.ic_baud;
bean.title = "波特率";
bean.spKey = SPKey.BAUD_RATE;
bean.value = String.valueOf(mBaudRate);
for (LeftDetailBean leftDetailBean : list) {
bean.addSubItem(leftDetailBean);
}
return bean;
}
代码示例来源:origin: Deemonser/AndroidSerialPort
private LeftHeadBean getLeftCheckDigitBean() {
ArrayList<LeftDetailBean> list = new ArrayList<>();
int[] array = Utils.getApp().getResources().getIntArray(R.array.check_digit);
for (int i : array) {
if (i == mCheckDigit) {
list.add(new LeftDetailBean(String.valueOf(i), true));
} else {
list.add(new LeftDetailBean(String.valueOf(i)));
}
}
LeftHeadBean bean = new LeftHeadBean();
bean.imageRes = R.mipmap.ic_check;
bean.title = "校验位";
bean.spKey = SPKey.CHECK_DIGIT;
bean.value = String.valueOf(mCheckDigit);
for (LeftDetailBean leftDetailBean : list) {
bean.addSubItem(leftDetailBean);
}
return bean;
}
代码示例来源:origin: Deemonser/AndroidSerialPort
private LeftHeadBean getLeftDataBitsBean() {
ArrayList<LeftDetailBean> list = new ArrayList<>();
int[] array = Utils.getApp().getResources().getIntArray(R.array.data_bits);
for (int i : array) {
if (i == mStopBit) {
list.add(new LeftDetailBean(String.valueOf(i), true));
} else {
list.add(new LeftDetailBean(String.valueOf(i)));
}
}
LeftHeadBean bean = new LeftHeadBean();
bean.imageRes = R.mipmap.ic_data;
bean.title = "数据位";
bean.spKey = SPKey.DATA_BITS;
bean.value = String.valueOf(mDataBits);
for (LeftDetailBean leftDetailBean : list) {
bean.addSubItem(leftDetailBean);
}
return bean;
}
代码示例来源:origin: Deemonser/AndroidSerialPort
private LeftHeadBean getLeftStopBitsBean() {
ArrayList<LeftDetailBean> list = new ArrayList<>();
int[] array = Utils.getApp().getResources().getIntArray(R.array.stop_bits);
for (int i : array) {
if (i == mStopBit) {
list.add(new LeftDetailBean(String.valueOf(i), true));
} else {
list.add(new LeftDetailBean(String.valueOf(i)));
}
}
LeftHeadBean bean = new LeftHeadBean();
bean.imageRes = R.mipmap.ic_stop;
bean.title = "停止位";
bean.spKey = SPKey.STOP_BIT;
bean.value = String.valueOf(mStopBit);
for (LeftDetailBean leftDetailBean : list) {
bean.addSubItem(leftDetailBean);
}
return bean;
}
代码示例来源:origin: yangchong211/YCAudioPlayer
@Override
public void accept(Throwable throwable) throws Exception {
if (throwable instanceof RuntimeException) {
// 歌曲全部加载完成
recyclerView.showError();
return;
}
if (offset == 0) {
recyclerView.showError();
} else {
ToastUtils.showRoundRectToast(Utils.getApp().getResources().getString(R.string.load_fail));
}
}
}, new Action() {
代码示例来源:origin: ZhuoKeTeam/QPM
/**
* 获取剪贴板的uri
*
* @return 剪贴板的uri
*/
public static Uri getUri() {
ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
//noinspection ConstantConditions
ClipData clip = cm.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
return clip.getItemAt(0).getUri();
}
return null;
}
代码示例来源:origin: ZhuoKeTeam/QPM
/**
* 获取剪贴板的意图
*
* @return 剪贴板的意图
*/
public static Intent getIntent() {
ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
//noinspection ConstantConditions
ClipData clip = cm.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
return clip.getItemAt(0).getIntent();
}
return null;
}
}
代码示例来源:origin: yangchong211/YCAudioPlayer
DownloadManager downloadManager = (DownloadManager) Utils.getApp().getSystemService(Context.DOWNLOAD_SERVICE);
long id = 0;
if (downloadManager != null) {
内容来源于网络,如有侵权,请联系作者删除!