将字符串值类传递给另一个时遇到问题。在主类我有两个微调器和日期选择器,第一个微调器是位置,第二个是库存点名称。当选择位置时,它将在第二个微调器和选定日期显示相关的库存点,我将传递到URL中的3个字段以使用JSON。 item,item1,date是fields。
url0 = "http://10.0.2.2:51382/RestServiceImpl.svc/json/?Location="+item+"&GROUP="+item1+"&asondate="+date;
我想将字符串url0传递给另一个类,我在调用该类时传递了它,它强制关闭了logcat show
06-28 12:09:45.998 612-612/com.android.exchange E/StrictMode: null
android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d31660 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
at android.app.ContextImpl.bindService(ContextImpl.java:1418)
at android.app.ContextImpl.bindService(ContextImpl.java:1407)
at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
答案 0 :(得分:0)
如果你只使用一种类型的url和item,item1,date会有所不同,那么在Intent中只传递你的三个值,并从另一个类的Bundle中获取它。你可以在你的URL中设置这个值。
传递值:
Intent intent = new Intent(getBaseContext(), SecondActivity.class);
intent.putExtra("EXTRA_item", item);
intent.putExtra("EXTRA_item1", item1);
intent.putExtra("EXTRA_date", date);
startActivity(intent);
获取SecondActivity中的值:
Intent intent = getIntent();
String item = intent.getStringExtra("EXTRA_item");
String item1 = intent.getStringExtra("EXTRA_item1");
String date = intent.getStringExtra("EXTRA_date");
现在设置你的url0。