Skip to content

Instantly share code, notes, and snippets.

View wutianlong's full-sized avatar

Superman wutianlong

View GitHub Profile
@wutianlong
wutianlong / NavigationBar
Created April 28, 2017 03:24
judge weather have navigation bar, if want to know navigation bar at left or bottom , can through judge screen-size
//获取是否存在NavigationBar
public static boolean checkDeviceHasNavigationBar(Context context) {
boolean hasNavigationBar = false;
Resources rs = context.getResources();
int id = rs.getIdentifier("config_showNavigationBar", "bool", "android");
if (id > 0) {
hasNavigationBar = rs.getBoolean(id);
}
try {
Class systemPropertiesClass = Class.forName("android.os.SystemProperties");
package com.sohu.tv.ui.util;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.support.v4.view.ViewCompat;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
@wutianlong
wutianlong / isInstallApp
Created March 27, 2017 07:05
judge app is installed
public class IsInstalled {
public static boolean isIntalled(Context context, String packageName) {
boolean exist = false;
PackageManager pm = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(intent, 0);
for (ResolveInfo resolveInfo : resolveInfoList) {
if (resolveInfo.activityInfo.packageName.equals(packageName)) {
@wutianlong
wutianlong / tools:overrideLibrary
Created January 16, 2017 08:48
覆盖library
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-sdk tools:overrideLibrary="com.facebook.drawee,
com.facebook.drawee.backends.pipeline,
com.facebook.fbcore, com.facebook.imagepipeline,
com.facebook.imagepipelinebase, com.facebook.animated.webp,
com.facebook.imagepipeline.animated" />
private void deleteBars() {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
decorView.setSystemUiVisibility(uiOptions);
}
oldActvity=""
displayName=""
currentActivity=`adb shell dumpsys window windows | grep -E 'mCurrentFocus'`
while true
do
if [[ $oldActvity != $currentActivity && $currentActivity != *"=null"* ]]; then
displayName=${currentActivity##* } // 删除最后一个空格,及其左面的字符串
displayName=${displayName%%\}*} // 删掉第一个\ } 及其右面字符串
echo $displayName
oldActvity=$currentActivity
1. 项目根目录下 build.gradle 配置
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.tencent.bugly:symtabfileuploader:latest.release'
@wutianlong
wutianlong / getCenterInBitmap
Created July 26, 2016 07:09
获取图片指定大小中间,剪裁周边
/**
* 获取中间的方形图片,超出时截取两边
*
* @param srcBitmap
* @param size 最终正方形的边长
* @return
* @throws OutOfMemoryError
*/
public static Bitmap getCenterInBitmap(Bitmap srcBitmap, int dstWidth, int dstHeight) {
Bitmap finalBm = null;
#/bin/bash
for i in {1..300};
do
adb shell input tap 800 800
sleep 10
adb shell input keyevent 4
adb shell input keyevent 4
echo "================"
#adb shell dumpsys meminfo com.sohuvideo.sdk_open |grep TOTAL
#echo "----------------"
不使用 AIDL的情况下,进行跨进程通信IPC跨进程通信,通过messager 传递
以下代码是client向RemoteService发送消息,并返回给client
参考地址:http://mp.weixin.qq.com/s?__biz=MzA5MzI3NjE2MA==&mid=2650236008&idx=1&sn=c7a1f1de9ee92e6d7a2d00f04821a8c3&scene=0#wechat_redirect
http://www.cnblogs.com/freeliver54/archive/2012/06/13/2547739.html
1. Activity ==============
public class MainActivity extends AppCompatActivity {