android intent activity参数传递

1.java
Intent intent=new Intent(MainActivity.this,SecondActivity.class);
				Bundle bundle=new Bundle(); 
	            bundle.putString("mainstr", "第一个activity的内容"); 
	            intent.putExtras(bundle); 
				startActivity(intent);

2.java
 Intent intent = getIntent();
        Bundle buddle= intent.getExtras();
        System.out.println(buddle.getCharSequence("mainstr"));
        Toast.makeText(SecondActivity.this, buddle.getCharSequence("mainstr"), Toast.LENGTH_LONG);

3.AndroidManifest.xml
<activity
            android:name=".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=".SecondActivity"
            android:label="@string/app_name" >
        </activity>

你可能感兴趣的:(android,xml,intent,mainactivity)