杂项整理(1)

判断当前系统语言:

Locale.getDefault().getLanguage().toLowerCase().equals("ur")


当前activity堆信息的获取:

ActivityManager am = (ActivityManager)this.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);

List<RunningTaskInfo> list = am.getRunningTasks(5);

for (RunningTaskInfo info : list) {

className = info.topActivity.getClassName();
                if (className.equals("com.android.phone.InCallScreen") ||
                    className.equals("com.android.internal.app.ResolverActivity")) {
                    flg = true;
                }

来电大头贴无法正常显示:

frameworks/base/telephony/java/com/android/internal/telephony/CallerInfo.java中

public static Cursor getPhotoExistCursor(Cursor cursor){
               int cursorcount = cursor.getCount()/2;
               if(cursorcount > 1){
                       for(int i = 1; i < cursorcount; i++){
                               int first = cursor.getColumnIndex(PhoneLookup.PHOTO_ID);
                               int firstphotoid = cursor.getInt(first);
                               if(firstphotoid == 0){
                                       cursor.moveToNext();
                                       }
                               }
                       }
               return cursor;
       }

类似文件特定内容查询:

find . | grep ".mk" | xargs grep -nr "string"

获得联系人首字母A-Z或者#号:

private String getAlpha(String str) {  
        if (str == null) {  
            return "#";  
        }  
  
        if (str.trim().length() == 0) {  
            return "#";  
        }  
  
        char c = str.trim().substring(0, 1).charAt(0);  
        // 正则表达式,判断首字母是否是英文字母  
        Pattern pattern = Pattern.compile("^[A-Za-z]+$");  
        if (pattern.matcher(c + "").matches()) {  
            return (c + "").toUpperCase();  
        } else {  
            return "#";  
        }  
    }


你可能感兴趣的:(杂项整理(1))