[Java for Android App Development] hiphop12ism:
Hey there. i was experimenting with intents.. While I got stuck in this bug. I am almost positive, that my java classes have been coded correctly...

I think, its the android manifest.. The intent filters have not been setup correctly... However I will be posting.. all of my code and the logcat here...

Please help me.. Thanks in advance!

Manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.intents"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.intents.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.intents.SecondActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SecondActivity" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

</application>

</manifest>

activity_xml.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<Button
android:layout_width = "fill_parent"
android:layout_height="wrap_content"
android:text="Click for second Activity"
android:onClick="onClick"
android:id="@+id/button1"
/>

</RelativeLayout>

second_act.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/tvSecond"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter your name! " />

<Button
android:id="@+id/logOn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hit to Login"
android:onClick = "onClick" />

</LinearLayout>

MainActivity.java

package com.example.intents;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends Activity {
int request_Code = 1;

/** Called when the activity is first created. */
[MENTION=439709]override[/MENTION]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void onClick(View v) {

Intent i = new Intent("com.example.intents.MainActivity");
i.putExtra("str1", "This is str1");
i.putExtra("age1", 16);
Bundle ex = new Bundle();
ex.putString("str2", "this is str2 and a bundle String");
ex.putInt("age2", 22);
i.putExtras(ex);
startActivityForResult(i, 1);

}

protected void onActivityResult(int requestCode, int ResultCode, Intent data) {
if (requestCode == 1) {
if (ResultCode == RESULT_OK) {
Toast.makeText(this,
Integer.toString(data.getIntExtra("age3", 0)),
Toast.LENGTH_SHORT).show();
Toast.makeText(this, data.getData().toString(),
Toast.LENGTH_LONG).show();

}

}

}
}

SecondActivity.xml

package com.example.intents;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class SecondActivity extends Activity {

[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

setContentView(R.layout.second_act);

Toast.makeText(this, getIntent().getStringExtra("str1"),
Toast.LENGTH_SHORT).show();
Toast.makeText(this, getIntent().getIntExtra("age1", 0),
Toast.LENGTH_SHORT).show();
Bundle bundle = getIntent().getExtras();
Toast.makeText(this, bundle.getString("str2"), Toast.LENGTH_SHORT)
.show();
Toast.makeText(this, Integer.toString(bundle.getInt("age2")),
Toast.LENGTH_SHORT).show();

}

public void onClick(View v) {
Intent i = new Intent();
i.putExtra("age3", 45);
i.setData(Uri.parse("Something has been passed to main aactivity"));
setResult(RESULT_OK, i);
finish();
}

}

Logcat[only the portion highlighted in red! :p]

Uploaded here, for a better view..