我将活动分为两类:
ShipmentListActivity -> class ShipmentListActivity
-> class GetContacts (asynchronous processing of JSON data)
我尝试使用以下方法重定向此活动:
Intent activity = new Intent(ScanActivity.this,
ShipmentListActivity.class);
// pass data to next activity
activity.putExtra("list_of_found_shipments", result.toString());
startActivity(activity);
问题在于意图创建总是会出错:
ShipmentListActivity cannot be resolved to a type
如何在不分成2个独立类的情况下解决它?
感谢您的任何建议。
public class ShipmentListActivity extends ListActivity
{
private ProgressDialog pDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
// get shipment data passed from previous activity
Bundle extras = getIntent().getExtras();
if (extras != null) {
String value = extras.getString("list_of_found_shipments");
try {
jsonDataObject = new JSONObject(value);
} catch (JSONException e) {
Log.e(GlobalApplication.APP_LOG_NAMESPACE,
"JSONException convert");
e.printStackTrace();
}
}
// Calling async task to get json
new GetContacts().execute();
}
/**
* Async task class to get json by making HTTP call
* */
private class GetContacts extends AsyncTask<Void, Void, Void> {
…
}
}
答案 0 :(得分:0)
没有看到你的代码(不确定活动是什么意思&#34;分成两个类&#34;?)但是你需要给意图赋予派生自Activity的类。如果这是一个嵌套类,你需要这样做:
Intent activity = new Intent(ScanActivity.this, ShipmentListActivity.ShipmentListActivity.class);