我被分配了一个车辆跟踪系统项目,将作为Android应用程序开发。
项目简介: 给车辆驾驶员一个GPRS驱动的安卓手机安装电话,以便跟踪位置。假设所有路线坐标(纬度和经度)都已存储在DB中。因此,当驾驶员越过某个特定地点时,DB中应该有一个警报(状态变化)。这样,跟踪应该有效率。
我的问题: 我已经开发了程序但无法执行它。我想知道我的编码是完全错误还是我之间留下了一些东西。我附上/粘贴了该程序供您考虑。
我很乐意收到你的意见和帮助。看到项目执行的曙光。 你应该通过inbasharu@gmail.com与我联系 或者,如果你坦率地帮助我直接嗡嗡我@ 9659709092/7305738685
我的代码是:
1.proximity Alert Receiver
public class ProximityAlertReceiver extends BroadcastReceiver {
private static final String ACTIVE_TASK_LOC = "com.android.model.TaskLoc";
private static final String ACTIVE_TASK_TEXT = "com.android.model.TaskText";
private static final String ACTIVE_TASK_USER_ID = "com.android.model.TaskUserid";
private static final String ACTIVE_TASK_ROUTE_NUM = "com.android.model.TaskRoutenum";
private static final String ACTIVE_TASK_TOWARDS = "com.android.model.TaskTowards";
Ringtone r;
private static String url_create = "";
JSONParser jsonParser = new JSONParser();
private static final String TAG_SUCCESS = "success";
int id;
String taskLoc, taskText, taskRoutenum, taskUserid, taskTowards;
@Override
public void onReceive(Context context, Intent intent) {
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
ComponentName comp = new ComponentName(context.getPackageName(),
LocationProxyService.class.getName());
ComponentName service = context.startService(new Intent()
.setComponent(comp));
if (null == service) {
} else {
}
} else {
String key = LocationManager.KEY_PROXIMITY_ENTERING;
Boolean entering = intent.getBooleanExtra(key, false);
Bundle bundle = intent.getExtras();
taskLoc = bundle.getString(ACTIVE_TASK_LOC);
String taskText = bundle.getString(ACTIVE_TASK_TEXT);
String taskRoutenum = bundle.getString(ACTIVE_TASK_VEHICLE_NUM);
String taskUserid = bundle.getString(ACTIVE_TASK_USER_ID);
String taskTowards = bundle.getString(ACTIVE_TASK_TOWARDS);
if (entering) {
try {
enterLocation(context, "Task : \"" + taskText + "\"",
"You are Near to " + taskLoc, "UserId : \""
+ taskUserid + "\"", "Vehicle_no : \""
+ taskRoutenum + "\"", "Towrads : \""
+ taskTowards);
enterLocation(context, "Task : \"" + taskText + "\"",
"You are Near to " + taskLoc, "UserId : \""
+ taskUserid + "\"", "Vehicle_no : \""
+ taskRoutenum + "\"", "Towrads : \""
+ taskTowards);
} catch (Exception e) {
}
} else {
exitLocation(context, "Task : \"" + taskText + "\"",
"You are Leaving " + taskLoc + " already!");
}
}
}
public void enterLocation(Context context, String contentText,
String contentTitle, String contentUserid, String contentVehicle_no,
String contentTowards) {
Toast.makeText(context, contentText + "" + contentTitle,
Toast.LENGTH_SHORT).show();
Intent service = new Intent(context, set_routes.class);
context.startService(service);
new Ajax().execute();
}
public void exitLocation(Context context, String contentText,
String contentTitle) {
Toast.makeText(context, contentText + "" + contentTitle,
Toast.LENGTH_SHORT).show();
}
class Ajax extends AsyncTask<String, String, String> {// JSON STARTS HERE
// new CreateNewProduct().execute();
protected ArrayList<NameValuePair> parameters;
protected String v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11;
boolean success;
String msg = "";
public Ajax() {
super();
v1 = taskUserid;
v2 = taskRoutenum;
v3 = taskLoc;
v4 = taskTowards;
parameters = new ArrayList<NameValuePair>();
NameValuePair name = new BasicNameValuePair("user_id", v1);
NameValuePair mobile_no = new BasicNameValuePair("Vehicle_no", v2);
NameValuePair email = new BasicNameValuePair("current_stop", v3);
NameValuePair password = new BasicNameValuePair("towards", v4);
// NameValuePair address = new BasicNameValuePair("address", v9);
parameters.add(name);
parameters.add(mobile_no);
parameters.add(email);
parameters.add(password);
// parameters.add(address);
success = false;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
/*
* pDialog = new ProgressDialog(Newproduct.this);
* pDialog.setMessage("Creating Product..");
* pDialog.setIndeterminate(false); pDialog.setCancelable(true);
* pDialog.show();
*/
}
/**
* Creating product
* */
protected String doInBackground(String... args) {
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_create, "POST",
this.parameters);
// check log cat fro response
Log.d("Create Response", "asdf" + json.toString());
// check for success tag
try {
success = json.getBoolean(TAG_SUCCESS);
msg = json.getString("message");
if (success) {
id = json.getInt("id");
} else {
// failed to create product
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
if (success) {
Toast.makeText(getBaseContext(), "Sucessfully inserted" + id,
Toast.LENGTH_SHORT).show();
Intent i = new Intent(getApplicationContext(), set_vehicles.class);
startActivity(i);
} else {
Toast.makeText(getBaseContext(), msg, Toast.LENGTH_LONG).show();
Intent i = new Intent(getApplicationContext(), Main.class);
startActivity(i);
}
}
private Context getBaseContext() {
// TODO Auto-generated method stub
return null;
}
private Context getApplicationContext() {
// TODO Auto-generated method stub
return null;
}
private void startActivity(Intent i) {
// TODO Auto-generated method stub
}
}
}