自定义控件获取联网数据 点击崩溃

小傻家大叔 2016-05-06 08:51:32
在CustomerSpinner类里面,想要加载Spinner里面 其他类里面传过来的list集合,结果就经常崩溃。猜想是因为每次点击item时都需要加载这个类导致的,如果把list换成固定的字符串如"a","b","c"....就不会崩溃。现在写了一个静态代码块,发现效果跟以前还是一样,求下各位大神,这个怎么解决(公司项目)。

public class CustomerSpinner extends Spinner {
static {
if(list == null){
new Thread() {
public void run() {
HttpUtils ht = new HttpUtils();
jsonStr = ht.getJsonString("http://123.57.158.53:8090/cyz/officeEnviroment/getOfficeEnviroment.do"););

try {
// 总的json数组
JSONArray ja = new JSONArray(jsonStr);
// 目标json数组
JSONArray mja = ja.getJSONArray(2);
for (int i = 0; i < mja.length(); i++) {
// 每个json数组的目标信息
JSONObject jo = (JSONObject) mja.get(i);
list.add(jo.getString("officeName"));

}


} catch (JSONException e) {
e.printStackTrace();
}

}
}.start();
}

}

//构造方法
public CustomerSpinner(Context context) {
super(context);

list = new ArrayList<String>();


}
//构造方法
public CustomerSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
list = new ArrayList<String>();

this.context = getContext();
if (isInEditMode()) {
return;
}
CustomerSpinner.this.setAdapter(new BaseAdapter() {

@Override
public int getCount() {
return 1;
}

@Override
public Object getItem(int arg0) {
return null;
}

@Override
public long getItemId(int arg0) {
return 0;
}

@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
TextView text = new TextView(CustomerSpinner.this.getContext());
text.setText(list.get(arg0));
text.setTextColor(Color.BLACK);
text.setTextSize(15);
return text;
}
});

}

...全文
252 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hoyn 2016-05-06
  • 打赏
  • 举报
回复
哪里蹦了?多少行? 完整的Log贴出来啊,你这样说别人怎么帮你
小傻家大叔 2016-05-06
  • 打赏
  • 举报
回复
错误日志貌似跟这个没关系,我也看不懂。贴一下吧。 就这个错误。总结就三个。 1 》 E/DatabaseUtils(890): Writing exception to parcel E/DatabaseUtils(890): java.lang.SecurityException: No permission to write APN settings: Neither user 10331 nor current process has android.permission.WRITE_APN_SETTINGS. 2 》 com.tdc.cyz/com.tdc.cyz.page.home.ManagerCompanyRegister (server)' ~ Channel is unrecoverably broken and will be disposed! E/InputDispatcher(639): channel '43a754a0 com.tdc.cyz/com.tdc.cyz.page.manager.detail.CenterDetailActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 3》 E/SubmitMessage(2374): Submit string: submit:trigger=0,bugtype=2,modulename=com.tdc.cyz,level=1,testtype=NORMAL,path=/data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160429105110_crash 怎么解决呀,其他都是logServer 跟 logTrack的提示的错误。
哎,真难 2016-05-06
  • 打赏
  • 举报
回复
贴下错误日志就知道为啥会这样了
小傻家大叔 2016-05-06
  • 打赏
  • 举报
回复
抱歉,现在贴一下,求下大神帮忙解决。 05-06 13:46:44.500: E/InputDispatcher(639): channel '432917c8 com.tdc.cyz/com.tdc.cyz.page.home.ManagePage (server)' ~ Channel is unrecoverably broken and will be disposed! 05-06 13:46:44.500: E/InputDispatcher(639): channel '4384ea28 com.tdc.cyz/com.tdc.cyz.page.manager.detail.CenterDetailActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 05-06 13:46:44.500: E/InputDispatcher(639): channel '43171ff8 com.tdc.cyz/com.tdc.cyz.page.home.HomePage (server)' ~ Channel is unrecoverably broken and will be disposed! 05-06 13:46:44.510: E/dalvikvm(27406): could not disable core file generation for pid 27406: Operation not permitted 05-06 13:46:49.600: E/libEGL(27406): call to OpenGL ES API with no current context (logged once per thread) 05-06 13:46:49.670: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=10_100x100] 05-06 13:46:49.750: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=14_100x100] 05-06 13:46:49.750: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=12_100x100] 05-06 13:46:49.890: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=19_100x100] 05-06 13:46:49.890: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=17_100x100] 05-06 13:46:52.330: E/DatabaseUtils(872): Writing exception to parcel 05-06 13:46:52.330: E/DatabaseUtils(872): java.lang.SecurityException: No permission to write APN settings: Neither user 10387 nor current process has android.permission.WRITE_APN_SETTINGS. 05-06 13:46:52.330: E/DatabaseUtils(872): at android.app.ContextImpl.enforce(ContextImpl.java:1772) 05-06 13:46:52.330: E/DatabaseUtils(872): at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1801) 05-06 13:46:52.330: E/DatabaseUtils(872): at com.android.providers.telephony.TelephonyProvider.checkPermission(TelephonyProvider.java:1711) 05-06 13:46:52.330: E/DatabaseUtils(872): at com.android.providers.telephony.TelephonyProvider.query(TelephonyProvider.java:1268) 05-06 13:46:52.330: E/DatabaseUtils(872): at android.content.ContentProvider.query(ContentProvider.java:857) 05-06 13:46:52.330: E/DatabaseUtils(872): at android.content.ContentProvider$Transport.query(ContentProvider.java:200) 05-06 13:46:52.330: E/DatabaseUtils(872): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112) 05-06 13:46:52.330: E/DatabaseUtils(872): at android.os.Binder.execTransact(Binder.java:404) 05-06 13:46:52.330: E/DatabaseUtils(872): at dalvik.system.NativeStart.run(Native Method) 05-06 13:46:54.700: E/DatabaseUtils(872): Writing exception to parcel 05-06 13:46:54.700: E/DatabaseUtils(872): java.lang.SecurityException: No permission to write APN settings: Neither user 10387 nor current process has android.permission.WRITE_APN_SETTINGS. 05-06 13:46:54.700: E/DatabaseUtils(872): at android.app.ContextImpl.enforce(ContextImpl.java:1772) 05-06 13:46:54.700: E/DatabaseUtils(872): at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1801) 05-06 13:46:54.700: E/DatabaseUtils(872): at com.android.providers.telephony.TelephonyProvider.checkPermission(TelephonyProvider.java:1711) 05-06 13:46:54.700: E/DatabaseUtils(872): at com.android.providers.telephony.TelephonyProvider.query(TelephonyProvider.java:1268) 05-06 13:46:54.700: E/DatabaseUtils(872): at android.content.ContentProvider.query(ContentProvider.java:857) 05-06 13:46:54.700: E/DatabaseUtils(872): at android.content.ContentProvider$Transport.query(ContentProvider.java:200) 05-06 13:46:54.700: E/DatabaseUtils(872): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112) 05-06 13:46:54.700: E/DatabaseUtils(872): at android.os.Binder.execTransact(Binder.java:404) 05-06 13:46:54.700: E/DatabaseUtils(872): at dalvik.system.NativeStart.run(Native Method) 05-06 13:46:57.040: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=7_100x100] 05-06 13:46:57.220: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=9_100x100] 05-06 13:46:57.340: E/ImageLoader(27406): Image can't be decoded [http://123.57.158.53:8090/cyz/tbo/getTeamLogo.do?teamId=11_100x100] 05-06 13:46:57.920: E/logserver(237): Object Path:/data/system/dropbox/, mask=0x00000080 05-06 13:46:57.920: E/logserver(237): event->len=48, name=data_app_crash@1462513617929.txt 05-06 13:46:57.920: E/logserver(237): find_first_match: find match, plogs(type=1, pfile=/data/system/dropbox/, match=app_crash) 05-06 13:46:57.920: E/logserver(237): move_dir:src_path=/data/log/dbox/appdbg/logcache 05-06 13:46:57.920: E/logserver(237): move_dir:dst_path=/data/log/logcache/3876640/ 05-06 13:46:57.920: E/logserver(237): is_all_ready, any file is ready in non-keyfile exception. 05-06 13:46:57.920: E/logserver(237): extract_appname, forward search, appname=com.tdc.cyz 05-06 13:46:57.920: E/logserver(237): archive_and_send, pos=0, type=crash, output=20160506134657_crash 05-06 13:46:57.920: E/logserver(237): ---copy_match_files enter!!-- 05-06 13:46:57.920: E/logserver(237): [copy_match_files,805]: copy [/data/system/dropbox/data_app_crash@1462513617929.txt] to [/data/log/logcache/3876640/data_app_crash@1462513617929.txt] 05-06 13:46:57.920: E/logserver(237): internal_archive, argc=7 05-06 13:46:57.920: E/logserver(237): get_fault_appname, appname=com.tdc.cyz 05-06 13:46:57.920: E/logserver(237): handle_archive_exception, argc=7 05-06 13:46:57.920: E/logserver(237): get alarm time = 18554 (sec.)! 05-06 13:46:57.920: E/logserver(237): log_apr_add_record open file:/data/log/apr/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20150125174546_statistics 05-06 13:46:57.920: E/logserver(237): pack_file: count = 1 05-06 13:46:57.920: E/logserver(237): /data/log/logcache/3876640/ 05-06 13:46:57.920: E/logserver(237): move_input_files: name_count = 1 05-06 13:46:57.920: E/logserver(237): /data/log/logcache/3876640/ 05-06 13:46:57.920: E/logserver(237): move_input_files, create dir [/data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash] 05-06 13:46:57.920: E/logserver(237): copy_file_to_dir, /data/log/logcache/3876640/data_app_crash@1462513617929.txt -> /data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash 05-06 13:46:57.920: E/logserver(237): copy_file_to_dir, /data/log/logcache/3876640/finger.txt -> /data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash 05-06 13:46:57.920: E/logserver(237): notify_logcontrol: moduleName = com.tdc.cyz, output_name = 20160506134657_crash, file_prefix = P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_ 05-06 13:46:57.920: E/logserver(237): init_notify_fifo, before change /data/log/logcontrol owner 05-06 13:46:57.920: E/logserver(237): Process 338 opening FIFO for O_WRONLY 05-06 13:46:57.920: E/logserver(237): Process 338 opened fifo(19) 05-06 13:46:57.920: E/logserver(237): com.tdc.cyz: msg.szModuleName = 05-06 13:46:57.920: E/logserver(237): notify_logcontrol, 338 sent /data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash 05-06 13:46:57.920: E/logserver(237): thread_logcontrol, select ret = 1 05-06 13:46:57.920: E/logserver(237): handle_notify_event, read res = 324, client pid = 338, data=/data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash 05-06 13:46:57.920: E/logserver(237): get_bug_type_and_level: input = /data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash. 05-06 13:46:57.920: E/logserver(237): handle_notify_event, send msg [submit:trigger=0,bugtype=2,modulename=com.tdc.cyz,level=1,testtype=NORMAL,path=/data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash;] 05-06 13:46:57.920: E/logserver(237): send_to_client, send to (18) res = 163 05-06 13:46:57.920: E/logserver(237): check_dir_size, dir[/data/log/coredump/] doesn't exist 05-06 13:46:57.920: E/logserver(237): clean_cur_cache:938, system(rm -r /data/log/logcache/3876640/* > /dev/null 2>&1) 05-06 13:46:57.930: E/SubmitMessage(846): Submit string: submit:trigger=0,bugtype=2,modulename=com.tdc.cyz,level=1,testtype=NORMAL,path=/data/log/unzip/P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20160506134657_crash 05-06 13:46:57.950: E/logserver(237): Object Path:/data/log/apr/, mask=0x00000008 05-06 13:46:57.950: E/logserver(237): event->len=80, name=P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20150125174546_statistics 05-06 13:46:57.950: E/logserver(237): process_one_event, can not find this event(P7-L05_V100R001CHNC00B125SP01_7N2MWW144P011979_20150125174546_statistics) 05-06 13:46:57.950: E/logserver(237): clean_cur_cache:938, system(rm -r /data/log/logcache/3876640/* > /dev/null 2>&1) 05-06 13:46:58.980: E/LogTrack(846): user type is COMMERCIAL_USER 05-06 13:46:58.990: E/LogTrack(846): user type is COMMERCIAL_USER 05-06 13:47:00.300: E/InputDispatcher(639): channel '437d4e78 com.tdc.cyz/com.tdc.cyz.page.manager.detail.CenterDetailActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 05-06 13:47:00.300: E/InputDispatcher(639): channel '428b4c90 com.tdc.cyz/com.tdc.cyz.page.home.ManagerCompanyRegister (server)' ~ Channel is unrecoverably broken and will be disposed! 05-06 13:47:00.300: E/InputDispatcher(639): channel '428cfbf8 com.tdc.cyz/com.tdc.cyz.page.home.ManagerRegisterProgress (server)' ~ Channel is unrecoverably broken and will be disposed! 05-06 13:47:00.320: E/dalvikvm(27508): could not disable core file generation for pid 27508: Operation not permitted

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧