zoukankan      html  css  js  c++  java
  • Android11 工厂测试应用

    一.一些问题

    1.1.Android中遇到button按钮设置背景图片无法显示的解决方案

    AS 4.2.版本

    <!-- Base application theme. -->
    Theme.MaterialComponents.DayNight.DarkActionBar ----> Theme.MaterialComponents.DayNight.DarkActionBar.Bridge

    <resources xmlns:tools="http://schemas.android.com/tools">
        <!-- Base application theme. -->
        <!--<style name="Theme.XH_Test" parent="Theme.MaterialComponents.DayNight.DarkActionBar">-->
        <style name="Theme.XH_Test" parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge">
        <!-- Primary brand color. -->
            <item name="colorPrimary">@color/purple_500</item>
            <item name="colorPrimaryVariant">@color/purple_700</item>
            <item name="colorOnPrimary">@color/white</item>

    1.2.Android11 文件存储 新建文件

    11-26 10:06:07.333 E/MediaProvider( 1075): insertFileIfNecessary failed
    11-26 10:06:07.333 E/MediaProvider( 1075): java.lang.IllegalArgumentException: Primary directory null not allowed for content://media/external_primary/file; allowed directories are [Download, Documents]
    11-26 10:06:07.333 E/MediaProvider( 1075):      at com.android.providers.media.MediaProvider.ensureFileColumns(MediaProvider.java:2923)
    11-26 10:06:07.333 E/MediaProvider( 1075):      at com.android.providers.media.MediaProvider.ensureUniqueFileColumns(MediaProvider.java:2588)
    11-26 10:06:07.333 E/MediaProvider( 1075):      at com.android.providers.media.MediaProvider.insertFile(MediaProvider.java:3282)
    11-26 10:06:07.333 E/MediaProvider( 1075):      at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:3826)
    11-26 10:06:07.333 E/MediaProvider( 1075):      at com.android.providers.media.MediaProvider.insert(MediaProvider.java:3537)
    11-26 10:06:07.333 E/MediaProvider( 1075):      at com.android.providers.media.MediaProvider.insertFileForFuse(MediaProvider.java:7187)
    11-26 10:06:07.333 E/MediaProvider( 1075):      at com.android.providers.media.MediaProvider.insertFileIfNecessaryForFuse(MediaProvider.java:7281)
    11-26 10:06:07.334 W/System.err( 4398): java.io.FileNotFoundException: /storage/emulated/0/voice_record.3gp: open failed: EPERM (Operation not permitted)
    11-26 10:06:07.334 W/System.err( 4398):         at libcore.io.IoBridge.open(IoBridge.java:492)
    11-26 10:06:07.334 W/System.err( 4398):         at java.io.RandomAccessFile.<init>(RandomAccessFile.java:289)
    11-26 10:06:07.334 W/System.err( 4398):         at java.io.RandomAccessFile.<init>(RandomAccessFile.java:152)
    11-26 10:06:07.334 W/System.err( 4398):         at android.media.MediaRecorder.prepare(MediaRecorder.java:1091)
    11-26 10:06:07.334 W/System.err( 4398):         at com.xinhua.model.VoiceRecordTest.startAudioRecording(VoiceRecordTest.java:71)
    

     代码

    sdFile = new File("/storage/external_sd/xinhua.txt");
    sdFile.createNewFile();
    

     解决方法  

    android:requestLegacyExternalStorage="true"    

    1.3.Android 11  打开WiFi设置开关   

    WIFI on:
    adb shellsvc wifi enable
    WIFI off:
    adb shell svc wifi disable
    

     扫描WiFi列表

    a.清单文件 加WiFi权限

        <!--wifi-->
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    

    b.startScan

            mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
            mTelephony = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
            //mWifiManager.setWifiEnabled(true);
            Toolkit.RootCommand("svc wifi enable");
            mWifiManager.startScan();  

     1.4.添加lib库

    build.grade

        sourceSets {
            main {
                jni {
                    srcDirs 'src/main/jni', 'src/main/jniLibs'
                }
            }
        }
    

      

     

     

  • 相关阅读:
    最火的.NET开源项目[转]
    ExtJs4.1目录结构介绍和使用说明[转]
    mvc4 Forms验证存储 两种登录代码
    微服务 第九章 springboot 使用NoSql数据库:redis
    【数据挖掘】关联分析之Apriori(转载)
    C语言面试
    10.15习题2
    java 执行linux命令
    servlet tomcat eclipse
    002_监测ssl证书过期时间
  • 原文地址:https://www.cnblogs.com/crushgirl/p/15619790.html
Copyright © 2011-2022 走看看