chips

  1. 在使用SharedPreferences的时候,写入数据要用临时变量的edit,不能分开写。

错误如下:

SharedPreferences sharedPreferences = getSharedPreferences("NfcRecord", Activity.MODE_PRIVATE);
sharedPreferences.edit().putString("deviceid", mDeviceId);
sharedPreferences.edit().putString("labelname", mLabelName);
sharedPreferences.edit().apply();

正确如下:

SharedPreferences sharedPreferences = getSharedPreferences("NfcRecord", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("deviceid", mDeviceId);
editor.putString("labelname", mLabelName);
editor.apply();

2.在linux kernel的driver中写可以被apk读取的文件,

static int test_save_data(void)
{
    struct file *fp;
    mm_segment_t fs;
    loff_t pos;
    printk("test_save_data enter\n");
    fp =filp_open("/data/.nrfdata", O_CREAT|O_RDWR, 0644);
    if (IS_ERR(fp)){
        printk("create file error, error=%ld\n", PTR_ERR(fp));
        return -1;
    }
    fs =get_fs();
    set_fs(KERNEL_DS);
    pos =0;
    vfs_write(fp, tag_info_buffer, sizeof(tag_info_buffer), &pos);
    filp_close(fp,NULL);
    set_fs(fs);
    return 0;
}

3.获取当前时间的字符串:

String mTimeStamp = new java.text.SimpleDateFormat("yyyyMMddhhmmss").
          format(new java.util.Date(Calendar.getInstance().getTimeInMillis()));

4.拷贝

#TARGET_PRODUCT_OUT = out/target/product/$(TARGET_PRODUCT)
#$(shell mkdir -p $(TARGET_PRODUCT_OUT)/system/app)
#$(shell cp -rf $(PREINSTALL_APP_DIR)/app $(TARGET_PRODUCT_OUT)/system/)
#$(shell cp -rf $(PREINSTALL_APP_DIR)/lib $(TARGET_PRODUCT_OUT)/system/)

5.自动弹出U盘修改:

打开终端
禁止自动挂载:
$ gsettings set org.gnome.desktop.media-handling automount false
禁止自动挂载并打开
$ gsettings set org.gnome.desktop.media-handling automount-open false
允许自动挂载
$ gsettings set org.gnome.desktop.media-handlingautomount true
允许自动挂载并打开
$ gsettings set org.gnome.desktop.media-handling automount-open true

6.默认adb不打开,在UsbDeviceManager.java中public UsbHandler(Looper looper)里边实现:

persist.service.adb.enable=0

7.ubuntu 设置hosts

sudo gedit /etc/hosts

修改完hosts后再重启网络

sudo /etc/init.d/networking restart

results matching ""

    No results matching ""