我正在尝试将 Notification 对象写入文件。我能找到的最好方法是将对象写入包裹,编组该包裹以获取字节 [],然后将其写入文件。
Parcel notif = Parcel.obtain();
notification.writeToParcel(notif, 0);
byte[] notifArray = notif.marshall();
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试编组包裹时出现运行时异常:“试图编组包含 Binder 对象的包裹。”
有没有更好的方法将 Notification 对象写入文件?否则,我如何让这种方法发挥作用?
我正在尝试使用DllImport将dll导入到我的C#项目中,如下所示:
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key,string val,string filePath);
Run Code Online (Sandbox Code Playgroud)
另外,我添加了命名空间System.Runtime.InteropServices:
using System.Runtime.InteropServices;
Run Code Online (Sandbox Code Playgroud)
不过,我收到一个错误:"当前上下文中不存在名称'DllImport'"
是否可以在类中的哪个位置导入dll?