GithubからダウンロードしたAndroidアプリのソースコードを使用しています。コードには主なアクティビティーが1つしかありません。そこで、ユーザーがアプリケーションを実行するたびにスプラッシュ画面を表示するための別のアクティビティを作成することにしましたが、スプラッシュ画面を作成した後は、アプリケーションはもう実行されません。スプラッシュ画面を作成した後にアプリケーションを起動したくない
スプラッシュActivityクラスの抜粋:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread myThread = new Thread() {
@Override
public void run() {
try {
sleep(2000);
Intent intent = new Intent(getApplicationContext(),
MainActivity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
myThread.start();
//.....
}
そして、これはAndroidManifest.xmlをあるファイル:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.csab.soundboard">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".SplashActivity"
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=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_splash"
android:parentActivityName=".SplashActivity"
android:theme="@style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.csab.soundboard.MainActivity" />
</activity>
</application>
</manifest>
これは私が上のアプリを実行したときに、私が得るものです仮想デバイス:
を追加するlogcatとビューメッセージを追加するAndroidモニターの概要 –