小编soh*_*hil的帖子

编组通知包

我正在尝试将 Notification 对象写入文件。我能找到的最好方法是将对象写入包裹,编组该包裹以获取字节 [],然后将其写入文件。

Parcel notif = Parcel.obtain();
notification.writeToParcel(notif, 0);
byte[] notifArray = notif.marshall();
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试编组包裹时出现运行时异常:“试图编组包含 Binder 对象的包裹。”

有没有更好的方法将 Notification 对象写入文件?否则,我如何让这种方法发挥作用?

notifications android marshalling parcel

5
推荐指数
1
解决办法
1763
查看次数

在C#中导入DLL

我正在尝试使用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?

.net c# dll dllimport

4
推荐指数
1
解决办法
3万
查看次数

标签 统计

.net ×1

android ×1

c# ×1

dll ×1

dllimport ×1

marshalling ×1

notifications ×1

parcel ×1