public class Map extends Activity {
private NotificationManager nm;
private int UniqueID = 100;
private ImageView selectedImage;
private Bitmap currentImage;
float xval;
float yval;
float xx1, xx2, xx3, yy1, yy2, yy3;
JSONObject json;
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
private static final String LOGIN_URL = "http://www.digiassistant.comuf.com/get/getbeacon.php";
private static final String TAG_SUCCESS = "success";
private static final String TAG_MESSAGE = "message";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
selectedImage = (ImageView) findViewById(R.id.selectedImage);
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
int width = 500;
int height = 600;
LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(width,
height);
selectedImage.setLayoutParams(parms);
new AttemptLogin().execute();
Button openGallery = (Button) findViewById(R.id.opengallery);
MyCustomPanel view = new MyCustomPanel(this);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
addContentView(view, params);
openGallery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
}
});
}
private class MyCustomPanel extends View {
public MyCustomPanel(Context context) {
super(context);
}
@Override
public void draw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.GREEN);
paint.setStrokeWidth(50);
paint.setColor(Color.RED);
canvas.drawCircle(x, y, 10, paint);
}
}
class AttemptLogin extends AsyncTask<string,> {
boolean failure = false;
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Map.this);
pDialog.setMessage("Attempt login...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected String doInBackground(String... args) {
SharedPreferences sharedpreferences = getSharedPreferences(
Login.MyPREFERENCES, Context.MODE_PRIVATE);
String username = sharedpreferences.getString(Login.name, null);
int success;
try {
List<namevaluepair> params = new ArrayList<namevaluepair>();
params.add(new BasicNameValuePair("username", username));
Log.d("request!", "starting");
json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", params);
Log.d("Login attempt", json.toString());
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
Log.d("Login Successful!", json.toString());
return json.getString(TAG_MESSAGE);
} else {
Log.d("Login Failure!", json.getString(TAG_MESSAGE));
return json.getString(TAG_MESSAGE);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
try {
JSONArray user = json.getJSONArray("user");
JSONObject jb = user.getJSONObject(0);
float xx1 = jb.getLong("xx1");
float xx2 = jb.getLong("xx2");
float xx3 = jb.getLong("xx3");
float yy1 = jb.getLong("yy1");
float yy2 = jb.getLong("yy2");
float yy3 = jb.getLong("yy3");
} catch (Exception e) {
e.printStackTrace();
}
if (file_url != null) {
Toast.makeText(Map.this, file_url, Toast.LENGTH_LONG).show();
}
}
i need to pass the variables xx1 yy1 to draw in canvas, where x and y in drawccircle
() must set with xx1 and yy1
[edit]Code block added - OriginalGriff[/edit]