开始Activity代码:
Intent in = new Intent(); in.putExtra("str", "欢迎测试");// in.setClass(TestActivity02Activity.this, TestActivtiy03.class); TestActivity02Activity.this.startActivity(in);
必须配置AndroidManifest.xml代码:
<activity android:name=".TestActivity02Activity" 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=".TestActivtiy03" android:label="测试"></activity>//跳转到的activity在xml注册
跳转到的activity取值:
Intent in =getIntent(); String str = in.getStringExtra("str"); Toast.makeText(TestActivtiy03.this,"提示:"+str,Toast.LENGTH_LONG).show();
来源:https://www.cnblogs.com/b422/archive/2012/10/17/test_Activity.html