大家好,这是我的第一个android编码,我试图在活动之间切换,但我不能简单地找到我的错误在哪里。当应用程序在活动之间切换时,“应用程序已停止”
主要在这里;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
protected void start()
{
Intent k= new Intent(MainActivity.this, Try.class);
startActivity(k);
finish();
}
而我的清单在这里,我的第二个活动名称是“尝试”;
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.ege.intent.Try"
android:label="@string/app_name" >
</activity>
</application>
谢谢。
请粘贴记录的错误 – fn5341
是否有错误日志?你有没有用button或其他东西来调用start()? –
对不起,我怎样才能得到日志? –