Я хочу знать,
, откуда приходит,
который clickListener щелкают в onActivityResult.как проверить, какие OnClick есть в onActivityResult
Может ли кто-нибудь дать мне пример для примера?
где я должен редактировать?
как мне отредактировать?
Regist_Slide_Images.java
iv_slide1 = (ImageView) findViewById(R.id.iv_slide1);
iv_slide2 = (ImageView) findViewById(R.id.iv_slide2);
iv_slide1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent Intent = new Intent(Regist_Slide_Images.this, CheckUpload.class);
Intent.putExtra("calling-activity", ActivityConstants.ACTIVITY_4);
startActivityForResult(Intent, 1);
}
});
iv_slide2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent Intent = new Intent(Regist_Slide_Images.this, CheckUpload.class);
Intent.putExtra("calling-activity", ActivityConstants.ACTIVITY_5);
startActivityForResult(Intent, 1);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
if(requestCode == 1) {
int callingActivity = getIntent().getIntExtra("calling-activity", 0);
switch (callingActivity) {
case ActivityConstants.RESULT_1:
//data.putExtra("image_name",a);
a = data.getStringExtra("image_name");
if(a != null)
{
//Start download
Uri.Builder builder = new Uri.Builder();
builder.scheme("http")
.authority("192.168.200.200")
.appendPath("AndroidFileUpload")
.appendPath("select_image.php")
.appendQueryParameter("slide", a);
myUrl = builder.build().toString();
b = null;
}
break;
case ActivityConstants.RESULT_2:
//data.putExtra("image_name2", a);
b = data.getStringExtra("image_name2");
if(b != null)
{
//Start download
Uri.Builder builder = new Uri.Builder();
builder.scheme("http")
.authority("192.168.200.200")
.appendPath("AndroidFileUpload")
.appendPath("select_image.php")
.appendQueryParameter("slide", b);
myUrl = builder.build().toString();
a = null;
}
break;
}
asyncTask.delegate = this;
asyncTask.execute(myUrl);
ActivityConstants.java
public interface ActivityConstants {
public static final int ACTIVITY_1 = 1001;
public static final int ACTIVITY_2 = 1002;
public static final int ACTIVITY_3 = 1003;
public static final int ACTIVITY_4 = 1004;
public static final int ACTIVITY_5 = 1005;
public static final int RESULT_1 = 101;
public static final int RESULT_2 = 102;
}
CheckUpload.java
//Grid view click event
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
//String a = String.valueOf(position);
String a = mGridData.get(position).getTitle();
//Toast.makeText(getApplication(), a, Toast.LENGTH_LONG).show();
int callingActivity = getIntent().getIntExtra("calling-activity", 0);
switch (callingActivity) {
case ActivityConstants.ACTIVITY_3:
Intent intent = new Intent(CheckUpload.this, DetailActivity.class);
intent.putExtra("title",a);
startActivity(intent);
break;
case ActivityConstants.ACTIVITY_4:
//Intent intent2 = getIntent();
//filePath2 = intent2.getStringExtra("Images2");
Intent intent2 = new Intent(CheckUpload.this, Regist_Slide_Images.class);
intent2.putExtra("image_name", a);
//intent2.putExtra("calling-activity", ActivityConstants.RESULT_1);
getIntent().putExtra("calling-activity", ActivityConstants.RESULT_1);
setResult(RESULT_OK, getIntent());
//setResult(RESULT_OK, intent2);
finish();
break;
case ActivityConstants.ACTIVITY_5:
//Intent intent2 = getIntent();
//filePath2 = intent2.getStringExtra("Images2");
Intent intent3 = new Intent(CheckUpload.this, Regist_Slide_Images.class);
intent3.putExtra("image_name2", a);
intent3.putExtra("calling-activity", ActivityConstants.RESULT_2);
setResult(RESULT_OK, intent3);
finish();
break;
}
хорошо жаль я отправляю в настоящее время – user3662974
Добавить другой код запроса для различных вызовов см сигнатуры методы: 'общественности недействительного startActivityForResult (Intent намерения, внутр requestCode)' –
Abhinav Puri мог бы вы Plase дать мне пример? – user3662974