Android : Force the user to select one photo in android

on Friday, September 26, 2014


In my android application in file activity_mai.xml I have for default in ImageView set the value of ic_launcher.png.



<ImageView
android:id="@+id/viewImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:contentDescription="@string/content"
android:src="@drawable/ic_launcher" />


I need check that when is executed the upload of image file the image not is ic_launcher and force the user to select one pic existent or taken new photo in his smartphone.


I have tried this method without success, because this check is not performed.


I suppose I'm not doing right but I know why.


I would greatly appreciate your help.


Thanks in advance


My code below:



@Override
public void onClick(View arg0) {

if (area.getSelectedItem().toString().trim()
.equalsIgnoreCase("area")) {
Toast.makeText(MainActivity.this, "area.",
Toast.LENGTH_SHORT).show();
} else if (messageText.getText().toString().length() <= 0) {
Toast.makeText(MainActivity.this, "message",
Toast.LENGTH_SHORT).show();

} else if (arg0 == btnselectpic) {
selectImage();
} else if (arg0 == uploadButton) {

if (imageview.toString().equals("ic_launcher.png")) {
messageText.setError("image");
} else {
progress = ProgressDialog.show(MainActivity.this, "",
"Uploading file...", false, false);

int secondsDelayed = 5;
new Handler().postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(MainActivity.this,
MainActivity.class));
finish();
}
}, secondsDelayed * 1000);
}

0 comments:

Post a Comment