自编译OpenWRT固件

编译固件添加SSR+

编辑lede 目录下feeds.conf.default 文件,去掉下面的注释

src-git helloworld https://github.com/fw876/helloworld

执行下面的命令进行编译

./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
make -j8 download V=s
make -j1 V=s

二次编译:
1. git pull 
2. rm -rf ./tmp && rm -rf .config
3. 编辑lede 目录下feeds.conf.default 文件,添加
src-git helloworld https://github.com/fw876/helloworld
4. ./scripts/feeds clean
./scripts/feeds update -a && ./scripts/feeds install -a
5. make menuconfig
6. make -j8 download
make -j$(($(nproc) + 1)) V=s

git pull的时候可能会报错,执行
1 git reset --hard
2 git pull
就可以修复。

参考链接:
https://ssr.tools/1420

https://github.com/coolsnowwolf/lede/issues/4410

https://github.com/fw876/helloworld

自编译OpenWRT固件,支持NanoPi NEO2(深度定制)
https://www.wygdbb.com/2020/05/19/diy-openwrt-for-pi-plus/

Android学习笔记:抓取U盘实际路径

  1. 创建接收器
public class USBReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

StorageManager mStorageManager = (StorageManager) context.getSystemService(Activity.STORAGE_SERVICE);
String action = intent.getAction();
Log.d(TAG, "receive broadcast\n"+action);
if(action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
   String path = intent.getData().getPath();
    //path = getCorrectPath(path);//获取正确的,完整的路径
    Log.d(TAG, "THE PATH IS:\n"+path);
}

}
}

2. 定义变量

USBReceiver usbBroadcast;

3. 在onCreate 下面注册广播

usbBroadcast = new USBReceiver();
IntentFilter usbFilter= new IntentFilter();
usbFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
usbFilter.addAction(Intent.ACTION_MEDIA_REMOVED);
usbFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
usbFilter.addDataScheme("file");
registerReceiver(usbBroadcast,usbFilter);

4. 程序退出前需要注销广播

参考链接:

https://blog.csdn.net/LJX_ahut/article/details/89672880

https://www.jianshu.com/p/42982aa8184

Android 学习笔记:接收广播开启activity时遇到Exception的问题

在别的安卓机器上调试成功的代码,在另外一台机器上测试的时候,发现收到广播启动activity的时候,会出现
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
的异常提示。网上搜了一下,发现必须设置Intent标志为FLAG_ACTIVITY_NEW_TASK。我是这样设置的:

 

Intent intentS= new Intent(getApplicationContext(), RunActivity.class);
intentS.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentS);

设置之后重新运行,就不会抛出上面的异常了。

本文参考链接:https://willy2016.pixnet.net/blog/post/215860320-android–api-%E7%B4%9A%E5%88%A5%E5%8D%87%E7%B4%9A-28%2C-android-pie-9.0-%E9%81%87%E5%88%B0-error