草庐IT

android - Pendingintent getbroadcast lost parcelable data

问题来了。我的程序在Android6.0上运行完美。将设备更新到android7.0.Pendingintent无法将parcelable数据传递给boradcastreceiver。这是代码。拉响警报publicstaticvoidsetAlarm(@NonNullContextcontext,@NonNullTodotodo){AlarmManageralarmManager=(AlarmManager)context.getSystemService(context.ALARM_SERVICE);Intentintent=newIntent(context,AlarmReceiv

android - 更新到 Kotlin 1.3.30 后 "Unresolved reference: Parcelize"

我在实验模式下长期使用Kotlin1.3.21和kotlin-android-extensions插件。今天,我只是通过修改版本切换到Kotlin1.3.30,现在无论我在哪里使用@Parcelize注释,我都会看到错误:未解析的引用:Parcelize。以下是我启用android扩展的方法:applyplugin:'kotlin-android-extensions'androidExtensions{experimental=truefeatures=["parcelize"]}请注意,我在没有明确声明所需功能的情况下进行了尝试,但效果不佳。另请注意,我使用的是GrrovyGrad

android - 什么是 Parcel.enforceInterface?

谁能告诉我Android的Parcel类中的enforceInterface方法是做什么的?开发者网站没有解释其目的,Google也没有返回任何有用的匹配。谢谢。 最佳答案 该方法在处理RPC调用时会检查客户端和服务端的接口(interface)是否相同。详细过程:客户端调用服务器远程方法,在调用mRemote.transact之前,该方法_data.writeInterfaceToken(DESCRIPTOR);会先调用。服务器端onTransact会被调用,然后调用data.enforceInterface(descriptor

android - Parcelable 和继承

这已经在SO上被问过几次了,但我的情况有点不同。我有实现Parcelable的A类。A类包含一些可以parceled的成员数据。它有自己的CREATOR并实现了writeToParcel()、describeContents()和一个接受Parcel的构造函数.有类B继承自类A。类B有额外的成员数据,但是它们都不需要分包。基本上,B类的parcelable数据与A类相同。如果我尝试将B放入一个Bundle中,将其传递给另一个Activity,然后再读取它,我将得到一个ClassCastException。我想这是意料之中的。经过反复试验,为了使B类可打包,我必须至少实现以下两点:pub

Android Binder 内部

我正在做一个项目,我们向android系统添加了一些非标准的安全功能,但我在调整Binder时遇到了一些严重的问题。有没有人对Binder系统有很深的了解,知道Binder为什么会“阻塞”一个传递Parcel的进程,接收进程又是如何解阻塞的? 最佳答案 这是Android文档中所说的预期行为:http://developer.android.com/reference/android/os/IBinder.htmlThekeyIBinderAPIistransact()matchedbyBinder.onTransact().The

android - 使用Gson实现parcelable接口(interface)

我正在尝试使用Gson实现parcelable接口(interface)。想法是创建一个json字符串(使用gson)并将其写入parcel对象。这是否是实现接口(interface)的正确方法?我遇到的唯一问题是在反序列化对象时。实际上,我使用gson来重新创建对象。privateMyClass(Parcelin){Stringjson=in.readString();Gsongson=newGson();gson.fromJson(json,getClass());}问题在于fromJson函数返回一个对象,该对象是构造函数应该创建的对象。最后一行代码应该是这样的this=gson

android - 在进程之间传递游标(Parcelable Cursor)

我需要将Cursor(SQLiteCursor)从服务传递到API10上的应用程序,并且很难找到一个像样的(和快速)解决方案。我看过CursorWindow类。这是Parcelable但我无法在API10上实例化此类以使用SQLiteCursor.fillWindow()因为它没有有效的构造函数。CursorWindow(boolean)已弃用。即使我得到一个包含来自SQLiteCursor的数据的CursorWindow实例,我如何将这个窗口复制到一个新的Cursor中?我应该为此使用什么Cursor实现?我看不到扩展AbstractWindowedCursor的可用Cursor。感

android - 将位图放入包中

我想使用AIDL将字符串和位图传递给服务。该服务实现了这个AIDL方法:voidaddButton(inBundledata);在我的例子中,Bundle包含一个字符串和一个位图。调用应用程序(客户端)有这段代码:...//AddtexttothebundleBundledata=newBundle();Stringtext="Sometext";data.putString("BundleText",text);//AddbitmaptothebundleBitmapicon=BitmapFactory.decodeResource(getResources(),R.drawable

android - Parcelable 相对于 JSON 的优势

我目前正在使用JSON(org.json)序列化我的一个数据类。当我在Bundle或Intent中传递它时,我只需在发送方调用.toString(),然后在接收方重新创建类。从到目前为止我读到的所有内容来看,出于性能考虑,我不应该实现Java的Serializable。我正在重写应用程序的某些部分,我正在考虑让我的数据类实现Parcelable并以这种方式传输它们。如果我这样做会有什么好处?如果我改用JacksonJSON库会更好吗?大多数JSON工作都是基于API的;服务器仅响应JSON。我还存储了一些JSON用于在应用程序端进行缓存。 最佳答案

android - AIDL 无法找到 Parcelable 类的定义

我有以下项目结构。我的StockInfo.java完全没问题。StockInfo.java(无错误)packageorg.yccheok.jstock.engine;importandroid.os.Parcel;importandroid.os.Parcelable;publicclassStockInfoimplementsParcelable{......StockInfo.aidl(无错误)packageorg.yccheok.jstock.engine;parcelableStockInfo;StockInfoObserver.aidl(错误!)packageorg.ycch