Android内存压力测试工具(memtester移植)

2023-10-29

该文章转载于:

android用memtester内存压力测试_W歹匕示申W的博客-CSDN博客

Android内存压力测试工具(memtester移植)_甜牛奶蛋糕的博客-CSDN博客_android 内存压力测试

DRR参考配置OK之后,首先需要的是对DDR进行压力测试保证DDR的稳定性,否则DDR出问题之后,很容易引起奇奇怪怪的问题,很难分析问题原因

memtester说明:

memtester主要用于测试内存稳定性
官网:https://pyropus.ca./software/memtester/old-versions/
版本:memtester-4.3.0.tar.gz(目前最新版本-2018.10.21)
官方已经预编译了大部分Linux系统的二进制文件,可以直接使用,现在我们将它移植到Android系统中。

移植

首先我们看看Makefile文件它在Linux系统是怎么编译的,这里移植memtester-4.3.0.tar.gz压缩包里的文件不需要任何修改。

memtester: \
$(OBJECTS) memtester.c tests.h tests.c tests.h conf-cc Makefile load extra-libs
	./load memtester tests.o `cat extra-libs`

从上面的Makefile可以知道,要编译memtester需要编译memtester.c和tests.c以及相关的头文件,所以我们可以写出下面的Android.mk文件。

​LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := memtester.c tests.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_MODULE := memtester
include $(BUILD_EXECUTABLE)

memtester-4.3.0.tar.gz解压到system/core/目录下,并命名为memtester目录,并把Android.mk放到同一目录。文件如下显示。

~/project$ tar -zxvf memtester-4.3.0.tar.gz -C AndroidO_8827LGO_20181207/system/core/
~/project$ cd AndroidO_8827LGO_20181207/system/core/memtester
~/project/AndroidO_8827LGO_20181207/system/core/memtester$tree
.
├── Android.mk
├── BUGS
├── CHANGELOG
├── conf-cc
├── conf-ld
├── COPYING
├── extra-libs.sh
├── find-systype.sh
├── make-compile.sh
├── Makefile
├── make-load.sh
├── make-makelib.sh
├── memtester.8
├── memtester.c
├── memtester.h
├── README
├── README.tests
├── sizes.h
├── tests.c
├── tests.h
├── trycpp.c
├── types.h
└── warn-auto.sh

先编译成模块进行测试:

~/project/AndroidO_8827LGO_20181207/system/core/memtester$ mm -j8
........
5 warnings generated.
[100% 6/6] Install: out/target/product/petrel-p1/system/bin/memtester
make: Leaving directory '/home/lemon/Develop/OrangePi_Lite2/android'


#### make completed successfully ####

然后就可以通过

adb push memtester /system/bin/
adb shell "chmod 777 /system/bin/memtester"
adb shell memtester 

最后添加到device.mk中,系统全编译时打包到系统,所以还需要在device.mk里面进行定义

PRODUCT_PACKAGES += memtester

测试

使用方法:Usage: memtester [-p physaddrbase [-d device]] [B|K|M|G] [loops],比如memtester 5M 1,对应测试1次5M内存

PS C:\Users\zhaojr\Documents\adb> ./adb root
adbd is already running as root
PS C:\Users\zhaojr\Documents\adb> ./adb remount
remount succeeded
PS C:\Users\zhaojr\Documents\adb> ./adb shell
8227LGO_demo:/ # memtester                                                                                                                               
memtester version 4.3.0 (32-bit)
Copyright (C) 2001-2012 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).

pagesize is 4096
pagesizemask is 0xfffff000
need memory argument, in MB

Usage: memtester [-p physaddrbase [-d device]] <mem>[B|K|M|G] [loops]

查看系统空闲内存,还有251M

8227LGO_demo:/ # free -h
free -h
                total        used        free      shared     buffers
Mem:             443M        432M         11M        328K        576K
-/+ buffers/cache:           431M         12M
Swap:            329M         73M        256M
8227LGO_demo:/ #

演示:memtester 5M 1,这里只是演示,测试1次5M内存,实际项目中这两个参数应尽可能大,才能覆盖整块内存,才能达到压力测试的结果,测试时失败有相应的log,我这里比较难复现就不贴了。

8227LGO_demo:/ # memtester 5M 1                                                                                                                          
memtester version 4.3.0 (32-bit)
Copyright (C) 2001-2012 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).

pagesize is 4096
pagesizemask is 0xfffff000
want 5MB (5242880 bytes)
got 5MB (5242880 bytes), trying mlock ...locked.
Loop 1/1:
  Stuck Address : ok         
  Random Value : ok
  Compare XOR : ok
  Compare SUB : ok
  Compare MUL : ok
  Compare DIV : ok
  Compare OR : ok
  Compare AND : ok
  Sequential Increment: ok
  Solid Bits : ok         
  Block Sequential : ok         
  Checkerboard : ok         
  Bit Spread : ok         
  Bit Flip : ok         
  Walking Ones : ok         
  Walking Zeroes : ok         

Done.
8227LGO_demo:/ #

Android APK的应用

主文件:
package com.example.ddr;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends Activity {
private static final String TAG = null;
private static TextView test_result = null;
static String test_setText = "";
static int Testing_times = 0;
String asdddd1 = "screencap -p /sdcard/screen1.png";
String asdddd2 = "screencap -p /sdcard/screen2.png";
String dir = "/data/data/com.example.ddr/files/";  
Context ctxDealFile = null;
String oldPath1 = "file:///android_asset/memtester";
String oldPath2 = "file:///memtester";
String newPath1 = Environment.getRootDirectory().getPath();//"system/";//"system/bin/";
String MemtesterFileName = "/data/memtester_result.txt";
String simpleMemtester_1 = "memtester -b -g -f 1190400--1190400 64M 1";
String complexMemtester_1 = "memtester -b -j 0 -k 4 -g -l 40 -a 64M";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        test_result = (TextView)findViewById(R.id.Memtester_01);
        System.out.println("csh ddr star");
        Memtester(simpleMemtester_1);
        Memtester(complexMemtester_1);
        //ReadTxtFile(MemtesterFileName);
        //copyFile(oldPath2,newPath1);
        /*String uiFileName = "memtester";
        
try {
ctxDealFile = this.createPackageContext("com.example.ddr",
Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}        
deepFile(ctxDealFile, uiFileName);*/
    }
    public void deepFile(Context ctxDealFile, String path) {
try {
String str[] = ctxDealFile.getAssets().list(path);
if (str.length > 0) {
System.out.println("csh deepFile 1");
File file = new File("/system/" + path);
file.mkdirs();
for (String string : str) {
path = path + "/" + string;
System.out.println("zhoulc:\t" + path);
// textView.setText(textView.getText()+"\t"+path+"\t");
deepFile(ctxDealFile, path);
path = path.substring(0, path.lastIndexOf('/'));
}
} else {
System.out.println("csh deepFile 2");
InputStream is = ctxDealFile.getAssets().open(path);
//FileOutputStream fos = new FileOutputStream(new File(getFilesDir().getAbsolutePath()+"/memtester"));
FileOutputStream fos = ctxDealFile.openFileOutput(path, 
ctxDealFile.MODE_WORLD_READABLE |ctxDealFile.MODE_WORLD_WRITEABLE);
byte[] buffer = new byte[1024];
int count = 0;
while (true) {
count++;
int len = is.read(buffer);
if (len == -1) {
break;
}
fos.write(buffer, 0, len);
}
is.close();
fos.close();

}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Process p;
Process p2;
try {
p = Runtime.getRuntime().exec("chmod 777 " + dir + path);
p.waitFor();
p2 = Runtime.getRuntime().exec("cp /data/data/com.example.ddr/files/memtester > /data/data/com.example.ddr/files/memtester2");
p2.waitFor();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    }
    public void  Memtester(String command)
    {
        Runtime r = Runtime.getRuntime();
        Process p;
        Testing_times ++;
            try {
                p = r.exec(command);
                BufferedReader br = new BufferedReader(new InputStreamReader(p
                        .getInputStream()));
                String inline;
                while ((inline = br.readLine()) != null) {
                    System.out.println(inline);
                }
                br.close();
p.waitFor();
ReadTxtFile(MemtesterFileName);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
    }
    /*public void  Memtester2(String command)
    {
    DataOutputStream os = null;
    Process p;
    try{
    p =Runtime.getRuntime().exec(isRoot?COMMAND_SU:COMMAND_SH);
    os = new DataOutputStream(p.getOutputStream());
    for (String command:commands){
    if(command==null){
    continue;
    }


    //donnotuseos.writeBytes(commmand),avoidchinesecharseterror
    os.write(command.getBytes());
    os.writeBytes(COMMAND_LINE_END);
    os.flush();


    try{
    }catch(Exception e){
    e.printStackTrace();
    }
    }*/
    public static String ReadTxtFile(String strFilePath)
    {
        String path = strFilePath;
        String content = "";
            File file = new File(path);
            if (file.isDirectory())
            {
                Log.d("TestFile", "The File doesn't not exist.");
            }
            else
            {
                try {
                    InputStream instream = new FileInputStream(file); 
                    if (instream != null) 
                    {
                        InputStreamReader inputreader = new InputStreamReader(instream);
                        BufferedReader buffreader = new BufferedReader(inputreader);
                        String line;
                        while (( line = buffreader.readLine()) != null) {
                            content += line + "\n";
                            //if(inline.equals("SUCCESS")){
                            if(line.indexOf("SUCCESS")!=-1){
                            test_setText += Testing_times + " : " + "SUCCESS \n";
                            test_result.setText(test_setText);
                            }else{
                            test_setText += Testing_times + " : " + "FAIL \n";
                            test_result.setText(test_setText);
                            }
                        }                
                        instream.close();
                    }
                }
                catch (java.io.FileNotFoundException e) 
                {
                    Log.d("TestFile", "The File doesn't not exist.");
                } 
                catch (IOException e) 
                {
                     Log.d("TestFile", e.getMessage());
                }
            }
            return content;
    }    


    /*
    private void simpleMemtester(){
    Log.d(TAG, "do simple memory test");
    openCmdList1.clear();
    try {
    openCmdList1.add("memtester -b -g -f 1190400--1190400 64M 1");
    exec(openCmdList1);
    memoryTestResult();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    private void complexMemtester(){
    Log.d(TAG, "do complex memory test");
    openCmdList1.clear();
    try {
    openCmdList1.add("memtester -b -j 0 -k 4 -g -l 40 -a 64M");
    exec(openCmdList1);
    memoryTestResult();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    
    */


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

APK预置到代码里面给个系统权限:

Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := ddr
include $(BUILD_PACKAGE)
# Use the following include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

配置文件配置手机UID权限:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.memtester_ckt"
    android:versionCode="1"
    android:versionName="1.0"
android:sharedUserId="android.uid.system">

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="21" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

把文件用android代码预置到手机system/bin下面,也就给手机配置了脚本环境:

CSH_DDR_PATH := packages/apps/ddr/assets
PRODUCT_COPY_FILES := $(CSH_DDR_PATH)/memtester:system/bin/memtester $(PRODUCT_COPY_FILES)

linux嵌入式环境下的使用:

#!/bin/sh

# Memory Tester Scripts
# by KaKa
# version = date
VERSION="Fri Oct 19 11:56:57 CST 2007"
# trap for irruptions
MEMTESTER=${PWD}/memtester
PPIDKILL=$$
SIDKILL=$$
trap "pkill -9 -P ${PPIDKILL};kill -9 $$" INT
trap "pkill -9 -P ${PPIDKILL};kill -9 $$" KILL
cat <<-EOF_vpps >&2
Version: ${VERSION}
PID: $$
PPIDKILL: ${PPIDKILL}
SIDKILL: ${PPIDKILL}
EOF_vpps
CORE_NUM=$(grep -i ^processor /proc/cpuinfo|wc -l)
MEMTESTERCOPY=${CORE_NUM}
MEM_TOTAL_K=$(awk '/^MemTotal/{print $2}'  /proc/meminfo)
MEM_RESERVE_PERCENTAGE=$((1000*50/1024))
MEM_RESERVED=$((MEM_TOTAL_K/1024*MEM_RESERVE_PERCENTAGE/1000))
MEM_TOTAL_TOBETESTED=$((MEM_TOTAL_K/1024-MEM_RESERVED))
MEM_PER_COPY=$((MEM_TOTAL_TOBETESTED/MEMTESTERCOPY))
RUN_DURATION_TIME=0
RUN_LOOPS=-1
RUN_DURATION_TIME_FLAG=0
RUN_LOOPS_FLAG=0
DDPERCOPY_TIME=6s
LOGDIR=/tmp/memtester-log-${$}
mkdir -p ${LOGDIR}

show_help () {
    cat <<HELPEOF >&2
    Version: ${VERSION}
    Usage: $(basename ${0})
    -r Directory: the root location of memtester binary file
    -c NUMBER: the copies of memtester should be run
    -m NUMBER: how many memory should be tested totally (in MB)
    -t TIME:   duration mode, how long will the tests go
    -l NUMBER: loops mode,how many loops will each memtester should go
    The option -t and -l are exclusive, which means tests could work
    only with   1. duration mode or 2. loops mode
    RUN 4 copies memtester with in 24 hours, to test total 4000 MB memory:
        $(basename ${0}) -t 24h -c 4 -m 4000
    RUN 2 copies memtester with in 1 hours, to test total 4000 MB memory:
        $(basename ${0}) -t 1h -c 4 -m 4000
    RUN 4 copies memtester with in 2 loops, to test total 3600 MB memory:
        $(basename ${0}) -l 2 -c 4 -m 3600
    -V/-h/-H: show this info.
HELPEOF
    exit 0
}

while getopts :c:m:t:l:r:p:hHVvx OPTION
do
    case ${OPTION} in
    c)
        #echo "-c ${OPTARG}"
        MEMTESTERCOPY=${OPTARG}
    ;;
    m)
        #echo "-m ${OPTARG} MB"
        MEM_TOTAL_TOBETESTED=${OPTARG}
        MEM_RESERVED=$((MEM_TOTAL_K/1024-MEM_TOTAL_TOBETESTED))
    ;;
    t)
        #echo "-t ${OPTARG}"
        [ 0 -ne ${RUN_LOOPS_FLAG} ] && echo "-t and -l are exclusive." && exit 222
        RUN_DURATION_TIME=${OPTARG}
        RUN_DURATION_TIME_FLAG=1
    ;;
    l)
        #echo "-l ${OPTARG}"
        [ 0 -ne ${RUN_DURATION_TIME_FLAG} ] && echo && echo "-t and -l are exclusive." && show_help && echo && exit 223
        RUN_LOOPS=${OPTARG};
        RUN_LOOPS_FLAG=1
    ;;
    d)
        #echo "-r ${OPTARG}"
        MEMTESTER=${OPTARG}/memtester
    ;;
    p)
        #echo "-p ${OPTARG}"
        MEMTESTER=${OPTARG}
    ;;
    V|h|H)
        show_help
    ;;
    v)
        set -v
    ;;
    x)
        set -x
    ;;
    ?)
        echo "Error...";
        echo "?Unknown args..."
        exit 224
    ;;
    *)
        #echo "*Unknown args..."
    esac
done
    #exit
[ 0 -eq ${RUN_DURATION_TIME_FLAG} ] && [ 0 -eq ${RUN_LOOPS_FLAG} ] &&
echo && echo "Please specified which mode should we run... -t or -l" &&
show_help && echo && exit 225
MEM_PER_COPY=$((MEM_TOTAL_TOBETESTED/MEMTESTERCOPY))
    echo "Mem total: " $((MEM_TOTAL_K/1024)) MB
    echo "Core total: "${CORE_NUM}
    echo "Memtester copys: " ${MEMTESTERCOPY}
    echo "Mem per copy: "${MEM_PER_COPY}
    echo "Mem total to used: "${MEM_TOTAL_TOBETESTED} MB
    if [ ${MEM_RESERVED} -lt 1 ]; then
        echo "Mem reserved: -- No more memory reserved..."
    else 
        echo "Mem reserved: "${MEM_RESERVED} MB
    fi
    #exit
    # GOGOGO
    if [ 0 -ne ${RUN_DURATION_TIME_FLAG} ]; then
        echo "Run within a duration: ${RUN_DURATION_TIME}"
    elif [ 0 -ne ${RUN_LOOPS_FLAG} ]; then
        echo "Run within a loop: ${RUN_LOOPS}"
    fi

    echo "Working directory: " $PWD
    echo "Memtester: " ${MEMTESTER}
    echo "LOGs directory: " $LOGDIR
    echo
    echo -n "Jobs started at date: "
    date #+%Y/%m/%d\ %H:%M
    echo
    #exit
########################
# Run testing within a duration time.
    if [ 0 -ne ${RUN_DURATION_TIME_FLAG} ]; then
    # prepareing the sleeping killers
        sleep ${RUN_DURATION_TIME}
        echo -n "End of testing(TIMEOUT)... "
        echo "KILL CHILD" && kill -9 $(pgrep -P ${PPIDKILL} memtester) && echo
        "Childen processes - KILLED."
        # attention to how the memtesters are forked...
        echo "KILL PARENT" && kill $$  && echo "KILLED." &
        echo "Finished the memtester"
        echo -n "Jobs finished at date: "
        date #+%Y/%m/%d\ %H:%M
    fi &
    echo -n "Waiting (PID: $$) for ${MEMTESTERCOPY}
    memtesters(${MEM_PER_COPY}MB for each). "
    if [ 0 -ne ${RUN_DURATION_TIME_FLAG} ]; then
        echo -n "For time: ${RUN_DURATION_TIME} "
    fi

    if [ 0 -ne ${RUN_LOOPS_FLAG} ]; then
        echo -n "For loops: ${RUN_LOOPS} "
    fi
    echo "..."
    while true
    do
        MEMTESTER_NUM=0
        echo -n "{"
        while [ ${MEMTESTER_NUM} -lt ${MEMTESTERCOPY} ]
        do
            echo -n " ${MEMTESTER_NUM} "
            if [ 0 -ne ${RUN_DURATION_TIME_FLAG} ]; then
                RUN_LOOPS=0
            fi
            ${MEMTESTER} ${MEM_PER_COPY} ${RUN_LOOPS} 2>&1 >> ${LOGDIR}/${MEMTESTER_NUM}.log &
    # set loops = 0 to make memtester run loop infinitely...
    # .pogo version will run only one loop by default
            sleep ${DDPERCOPY_TIME}
            MEMTESTER_NUM=$(expr $MEMTESTER_NUM + 1)
        done
        echo -n "}"
        wait
        [ 0 -ne ${RUN_LOOPS_FLAG} ] && break
        # memtesters' loops...
   done
########################
echo
echo -n "End of testing(Excution ended)... "
pkill -9 -P ${PPIDKILL}
kill $$
echo "Finished the memtester"
echo -n "Jobs finished at date: "
date #+%Y/%m/%d\ %H:%M

运行这个脚本:

sh memory.sh -c <number> -l <number> -m <memory>

-c:运行几个memtester

-l:运行几次

-m:测试多大的内存,直接填测试总数即可,程序会自动分配个平均值给每个memtester,这样省去我们自己的计算,也不用多开几个终端了,单位MB,例如我有一个四核CPU,32G 内存的机器,就可以这样运行:

sh memory.sh -c 4 -l 1 -m 3100

大家可以看这个脚本中还可以限定时间,例如我想运行24个小时

sh memory.sh -t 24h -c 4 -m 3100
 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android内存压力测试工具(memtester移植) 的相关文章

  • 如何创建在 React-Native 中检测自动位置的地图

    我已经在react native中创建了地图 参考https github com lelandrichardson react native maps https github com lelandrichardson react nat
  • 通过代码在创建时突出显示 ListView 项目

    我想在创建 listView 时突出显示 ListView 的第一行 0 我尝试了不同的方法 就像您在注释代码中看到的那样 但没有任何效果 这很奇怪 因为 OnItemClickListener 中的突出显示工作正常 它通过 xml 选择器
  • 使用同一个侦听器的多个活动

    我有 4 个活动 它们都包含一个 xml 页脚 其中包含 4 个按钮 每个活动一个 我现在想为这些按钮设置 onclicklistener 它是页脚中的自制菜单 问题是 如何使用侦听器以便重用代码 我有两个想法 创建一个实现 onclick
  • Android Camera.takePicture() 有时不返回?

    我正在编写一个Android 拍照应用程序 该代码在 onPreviewFrame byte data Cameracamera 中从预览中获取帧后进行一些处理 问题在于 android hardware Camera 的函数 takePi
  • 我无法再在后台应用程序中接收任何 FCM 消息

    当应用程序处于后台时 我无法再在应用程序中接收任何数据消息 请注意 直到最近它在我的应用程序中都运行良好 也许在我的开发环境最近更新后它停止工作了 我不能说 所以我尝试用快速入门 android 项目 https github com fi
  • CoordinatorLayout 和 ImageView 在滚动时调整宽度的问题

    我正在尝试放置一个ImageView in a CollapsingToolbarLayout它在加载时占据整个屏幕 并且当您滚动内容时 16x9 分辨率图像宽度会调整大小 直到图像占据屏幕的整个宽度 那时 我希望图像具有视差app lay
  • 如何在Android中的DataBinding的ViewModel类中获取R.string

    我目前正在使用databinding对于我的 Android 应用程序项目 我想设置error留言在我的CustomTextView from R string txtOldPassWordError并从另一个名为的类中进行设置ViewMo
  • 如何清除Android剪贴板?

    我发现的方法都不起作用 这是我尝试过的 1 使用clearPrimaryClip 的方法ClipboardManager class ClipboardManager clipboard ClipboardManager getSystem
  • Android L,使用 joda.time 库的异常

    该应用程序适用于所有设备 包括 nexus 5 和 nexus 7 在 Android L 预览版上运行相同的应用程序时 应用程序崩溃了 我一直在调试 并且调用 DateTime 构造函数发现了异常 public static String
  • 使用 DataBinding 测试片段时膨胀类 Fragment 时出错

    有人可以帮我解决这个问题吗 在我的测试中 我想检查登录按钮是否显示在起始页上 今天我已经为这个错误苦苦挣扎了一段时间 我不知道应该如何解决它 我在这里错过了什么 也许这个问题与这个问题有些相似 Espresso 测试失败 并显示 java
  • 什么是 Android 测试协调器?

    谷歌最近发布了Android测试支持库1 0 读完后overview https android developers googleblog com 2017 07 android testing support library 10 is
  • 如何绘制部分位图圆弧?类似于圆形进度轮,但具有显示得越来越多的位图。

    我正在寻找的是一种以顺时针圆形方式显示图像的视图 当进度为 25 时 应显示前 90 度 当进度为 100 时 应绘制完整的 360 度 它与使用 canvas drawArc 非常接近 但此方法仅适用于 Paint 对象 不适用于位图 其
  • Toast 消息消失后​​完成活动吗?

    有谁知道 是否有可能对 Toast 消息执行某些操作 在我的情况下完成活动 将被关闭 您只需创建一个Thread持续时间只要Toast显示 然后您就可以完成您的Activity public void onCreate Bundle sav
  • 如何在android中的谷歌地图上聚焦标记

    我只是想知道我们是否可以关注 Android 应用程序中添加的标记 如果是 怎么办 或者有没有其他方法可以完成这项任务 可以说我使用下面的代码添加了一个标记 map addMarker new MarkerOptions title tit
  • Jetpack Compose:制作全屏(绝对定位)组件

    我怎样才能在全屏渲染树的深处制作一个可组合的 类似于Dialog可组合作品 例如 当用户单击图像时 它会显示该图像的全屏预览 而无需更改当前路线 我可以用 CSS 来做到这一点position absolute or position fi
  • Android - 状态栏阻止全屏

    我的应用程序启动时可以全屏正确运行 然而 在最小化然后返回应用程序后 状态栏会弹出 并将我的视图向下推一点 如何防止状态栏移动我的视图 这是我的布局
  • 用于请求带有临时缓存的远程 Observable 的 RxJava 模式

    用例是这样的 我想暂时缓存最新发出的昂贵的Observable响应 但在它过期后 返回到昂贵的源Observable并再次缓存它 等等 一个非常基本的网络缓存场景 但我真的很难让它工作 private Observable
  • Android AppWidgetManager 方法 updateAppWidget 无法设置意图、加载数据。而且它是随机发生的

    我的小部件由 2 个按钮和一个显示数据的列表视图组成 大多数时候 当调用小部件提供程序的 onUpdate 方法时 一切都会正常加载 每个人都很高兴 但是我注意到有时在调用更新方法后 小部件完全无法加载其数据 列表视图为空 所有按钮均无响应
  • Android:透明活动问题

    最近 在我们的一款生产应用程序上 透明活动已停止工作 我的意思是它变成了黑色背景而不是透明背景 当我将活动的背景颜色设置为纯色 即红色 绿色等 时 它的应用不会出现问题 该问题可能是由于迁移到 AndroidX 引起的 但我没有这方面的证据
  • 如何从DataSource.Factory获取数据

    我必须调用此方法才能获取所有人员 我根本无法修改这个方法 Query SELECT FROM PERSON TABLE ORDER BY NAME DESC abstract fun getElements DataSource Facto

随机推荐