hello guys,
i have a main Activity called Main which has onActivityResult Method.
protected void onActivityResult(int requestCode, int resultCode, Intent data, Bundle extras)
{
Log.i("in OnActivityResult", "in OnActivityResult");
super.onActivityResult(requestCode, resultCode, data);
Log.i("in OnActivityResult", "in OnActivityResult");
ObjectInputStream ois = null;
if(requestCode == SUB_ACTIVITY_REQUEST_CODE)
{
Log.i("in OnActivityResult IFFFF", "in OnActivityResult IFFFF");
extras = getIntent().getExtras();
byte gpBytes[] = extras.getByteArray("gpBytes");
ByteArrayInputStream bis = new ByteArrayInputStream(gpBytes);
try
{
ois = new ObjectInputStream(bis);
gpObject = (GP) ois.readObject();
}
catch (StreamCorruptedException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Log.i("GP object Values", "GP object Values<<>>"+ this.gpObject.xValue + "and <<>>" + this.gpObject.yValue);
}
and in my second activity i wrote that code on button Action.
public void onClick(View v) {
Log.i("button", "button");
goToGrifReferenceAction();
GridReferenceActivity.this.setResult(RESULT_OK, getIntent().putExtra("gpObject", GridReferenceActivity.this.gpBytes));
GridReferenceActivity.this.finish();
}
so now problem is when the second activity finishes. onActivityResult does not call in main activity... can anybody tell me where i am going wrong.
and i am calling the second activity like this.
@Override
public void onClick(View v)
{
Intent i = new Intent(Main.this, GridReferenceActivity.class);
startActivityForResult(i, SUB_ACTIVITY_REQUEST_CODE);
}
and here is my menifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.anquetMap"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable = "true">
<activity android:name=".Main"
android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".GridReferenceActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.GridReferenceActivity"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
I'll be very thankful to him. Thanks a lot.