问题描述
我想将VideoView对象解析为json,以便可以使用jobparameters将其传递给Main Activity类以外的其他线程。
我的代码如下:
VideoView videoViewN = findViewById(R.id.video);
Gson g = new Gson();
String json = g.toJson(videoViewN); //this is the line that causes the error
PersistableBundle bundle = new PersistableBundle();
bundle.putString("VideoView",json);
JobInfo info = new JobInfo.Builder(123,componentName)
.setPersisted(true)
.setExtras(bundle)
.setPeriodic(5 * 60 * 1000)
.build();
但是它会引发如下错误:
2020-09-08 16:49:30.408 19352-19352/com.example.ses_adplatform_test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ses_adplatform_test,PID: 19352
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ses_adplatform_test/com.example.ses_adplatform_test.MainActivity}: java.lang.IllegalArgumentException: class android.widget.MediaController declares multiple JSON fields named mContext
我该如何解决?谢谢!
PS:之所以需要将其解析为json是因为jobparameters不接受字符串,int等以外的数据类型。我使用以下链接中的代码作为此解决方案的参考。 Android JobScheduling - I need to pass an object to my job but how?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)