This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final void collapseStatusBar(Context ctx) { | |
Object sbservice = ctx.getSystemService("statusbar"); | |
try { | |
Class<?> statusBarManager = Class.forName("android.app.StatusBarManager"); | |
Method collapse; | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
collapse = statusBarManager.getMethod("collapsePanels"); | |
} else { | |
collapse = statusBarManager.getMethod("collapse"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//数组方式处理 小数位有空格隔开 | |
function addCommas(val) { | |
var aIntNum = val.toString().split("."); | |
if (aIntNum[0].length >= 5) { | |
aIntNum[0] = aIntNum[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
} | |
if (aIntNum[1] && aIntNum[1] >= 5) { | |
aIntNum[1] = aIntNum[1] ? aIntNum[1].replace(/\B(?=(\d{3})+(?!\d))/g, " ") : " "; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//数组方式处理 小数位有空格隔开 | |
function addCommas(val) { | |
var aIntNum = val.toString().split("."); | |
if (aIntNum[0].length >= 5) { | |
aIntNum[0] = aIntNum[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
} | |
if (aIntNum[1] && aIntNum[1] >= 5) { | |
aIntNum[1] = aIntNum[1] ? aIntNum[1].replace(/\B(?=(\d{3})+(?!\d))/g, " ") : " "; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//开始旋转 | |
public void turnLeft(View v) { | |
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(v, "rotation", 0, -155, -135); | |
objectAnimator.setDuration(300); | |
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); | |
objectAnimator.start(); | |
hide.setVisibility(View.VISIBLE); | |
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 0.75f); | |
alphaAnimation.setDuration(300); | |
alphaAnimation.setFillAfter(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BluetoothUtils { | |
/** | |
* 开启蓝牙 | |
* | |
* @param v | |
*/ | |
public static void startBluetooth(View v, Intent intent, Activity activity) { | |
BluetoothAdapter bluetoothAdapter = BluetoothAdapter | |
.getDefaultAdapter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//权限 | |
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" /> | |
public static void deleteShortcut(Context context , String shortcutName , | |
Intent actionIntent , boolean isDuplicate) { | |
Intent shortcutIntent = new Intent ("com.android.launcher.action.UNINSTALL_SHORTCUT"); | |
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME ,shortcutName); | |
shortcutIntent.putExtra("duplicate" , isDuplicate); | |
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT , actionIntent); | |
context.sendBroadcast(shortcutIntent); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
显示: | |
InputMethodManager imm = (InputMethodManager)(getSystemService(Context.INPUT_METHOD_SERVICE)); | |
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); | |
隐藏: | |
InputMethodManager imm = (InputMethodManager)(getSystemService(Context.INPUT_METHOD_SERVICE)); | |
imm.hideSoftInputFromWindow(m_edit.getWindowToken(), 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String archiveFilePath="sdcard/download/Law.apk";//安装包路径 | |
PackageManager pm = getPackageManager(); | |
PackageInfo info = pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_ACTIVITIES); | |
if(info != null){ | |
ApplicationInfo appInfo = info.applicationInfo; | |
String appName = pm.getApplicationLabel(appInfo).toString(); | |
String packageName = appInfo.packageName; //得到安装包名称 | |
String version=info.versionName; //得到版本信息 | |
Toast.makeText(test4.this, "packageName:"+packageName+";version:"+version, Toast.LENGTH_LONG).show(); | |
Drawable icon = pm.getApplicationIcon(appInfo);//得到图标信息 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span style="font-size:14px;">package com.test.twiceexit; | |
import java.util.Timer; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.Message; | |
import android.view.KeyEvent; | |
import android.view.Menu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 从assets 文件夹中读取文本数据 */ | |
public static String getTextFromAssets(final Context context, String fileName) { | |
String result = ""; | |
try { | |
InputStream in = context.getResources().getAssets().open(fileName); | |
// 获取文件的字节数 | |
int lenght = in.available(); | |
// 创建byte数组 | |
byte[] buffer = new byte[lenght]; | |
// 将文件中的数据读到byte数组中 |
NewerOlder