I am tyring to figure out how to make an app that lets the users of the app post items for sale with pictures where other users that search it can view those items. For example something like craigslist for android. I want to set up an app where users can fill in edit texts like Category, Title, Price, Description and a Picture of the item they want to post for sale. How can I achieve this so users can search for items as well. From what I understand I have to take what a user is inputting for sale and send to a server so others can search it, right? Can anyone direct in a direction to get started, this is what I have for a user to post an item:
public class Post extends Activity implements OnClickListener {
ImageButton ibutton1;
ImageButton ibutton2;
ImageButton ibutton3;
ImageButton ibutton4;
ImageButton ibutton5;
ImageButton ibutton6;
Intent i1;
Intent i2;
Intent i3;
Intent i4;
Intent i5;
Intent i6;
final static int cameraData1 = 1;
final static int cameraData2 = 2;
final static int cameraData3 = 3;
final static int cameraData4 = 4;
final static int cameraData5 = 5;
final static int cameraData6 = 6;
Bitmap bmp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post);
Button button = (Button) findViewById(R.id.bNext);
button.setOnClickListener(mNextListener);
// Category spinner set up
Spinner cSpinner = (Spinner) findViewById(R.id.spCategoryPost);
ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(
this, R.array.category_array,
android.R.layout.simple_spinner_item);
adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cSpinner.setAdapter(adapter2);
cSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener2());
initialize();
}
private void initialize() {
ibutton1 = (ImageButton) findViewById(R.id.imageButton1);
ibutton2 = (ImageButton) findViewById(R.id.imageButton2);
ibutton3 = (ImageButton) findViewById(R.id.imageButton3);
ibutton4 = (ImageButton) findViewById(R.id.imageButton4);
ibutton5 = (ImageButton) findViewById(R.id.imageButton5);
ibutton6 = (ImageButton) findViewById(R.id.imageButton6);
ibutton1.setOnClickListener(this);
ibutton2.setOnClickListener(this);
ibutton3.setOnClickListener(this);
ibutton4.setOnClickListener(this);
ibutton5.setOnClickListener(this);
ibutton6.setOnClickListener(this);
}
public void onClick(View Images) {
switch (Images.getId()) {
case R.id.imageButton1:
i1 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i1, cameraData1);
break;
case R.id.imageButton2:
i2 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i2, cameraData2);
break;
case R.id.imageButton3:
i3 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i3, cameraData3);
break;
case R.id.imageButton4:
i4 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i4, cameraData4);
break;
case R.id.imageButton5:
i5 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i5, cameraData5);
break;
case R.id.imageButton6:
i6 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i6, cameraData6);
break;
}
}
private OnClickListener mNextListener = new OnClickListener() {
public void onClick(View v) {
EditText edit = (EditText) findViewById(R.id.etTitle);
EditText editP = (EditText) findViewById(R.id.etPrice);
EditText editD = (EditText) findViewById(R.id.etDescription);
long currentTime = System.currentTimeMillis();
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currentTime);
String showTime=String.format("%1$tI:%1$tM:%1$tS %1$Tp",cal);
Intent intent = new Intent(Post.this, PostSet.class);
intent.putExtra("com.mandam.isellibuy.TITLE", edit.getText().toString());
intent.putExtra("com.mandam.isellibuy.PRICE", editP.getText().toString());
intent.putExtra("com.mandam.isellibuy.DESC", editD.getText().toString());
intent.putExtra("currentTime", currentTime);
startActivity(intent);
}
};
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK){
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
ibutton1.setImageBitmap(bmp);
}
}
}
Now I take the value of all these edit texts, spinner, and images and return it to another activity where the user can view all of this to make sure it looks good and post the item for sale, here is the activity:
public class PostSet extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_set);
// Setting text of edit text tvTitle from class Post
TextView tv1 = (TextView) findViewById (R.id.tvTitleText);
TextView tv2 = (TextView) findViewById (R.id.tvPrice);
TextView tv3 = (TextView) findViewById (R.id.tvTimeStamp);
TextView tv4 = (TextView) findViewById (R.id.tvDescription);
Intent intent = getIntent();
String edit = intent.getStringExtra("com.mandam.isellibuy.TITLE");
String editP = intent.getStringExtra("com.mandam.isellibuy.PRICE");
String editD = intent.getStringExtra("com.mandam.isellibuy.DESC");
//long currentTime = extras.getLong("currentTime");
tv1.setText(edit);
tv2.setText(editP);
tv4.setText(editD);
//tv3.setText(currentTime);
}
}
Now this Activity just displays all the input from the user to look it over and there is a button “Submit” that the user clicks to submit the item for sale so others can view the item on my app. This is where I get confused how do I achieve that?
So the answer to your question in the title “does Android have a server…” is no. There’s no server that Google provides specifically for Android. However, Android can do standard network communication–you can use any accessible server of your choice. There are plenty of free (tiered) servers including Google App Engine, Heroku and AWS. You’ll have to create your own server-side component though.
You’re probably getting downvotes because the actual body of your question is extremely broad. I could probably reword your question as “How can I create Craigslist but for Android?”. There’s a lot involved and there are a huge range of possibilities and differing requirements. You need to break down your problem into pieces, fill in what you can and then if you have any specific technical questions about pieces of that, then ask those here on StackOverflow.
I will try to help you get started in the right direction as you asked though, you should take a look at learning how to implement a web service, then create one to post your listings to and to retrieve listings. In that web service you’ll have to interpret the request, and most likely save the data into a database. Likewise when retrieving listings, you’ll have to go to the database to retrieve previously stored listings, potentially filter/sort them and then return them in some form back.
This is not a trivial task, good luck.