Reputation: 828
I was trying to show a splash/welcome screen while my app is loading image data, the data load alright but the background image in splash.xml just won't show, I am posting my codes below.
public class Splash extends Activity {
private ChannelDB mDB;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
AppConnect.getInstance(this);
Thread splashThread = new Thread() {
@Override
public void run() {
try {
if (tabIsExist(null)==true){
mDB.Reset();
Bitmap bigbang1 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang1);
Bitmap bigbang2 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang2);
Bitmap bigbang3 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang3);
Bitmap bigbang4 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang4);
mDB.createchannelEntry(new ChannelPoster(bigbang1, "生活大爆炸(第一季)" ,"http://appkon.com/hdtvs/channel/bigbang1.xml" ,"http://movie.douban.com/subject/5372374/" ));
mDB.createchannelEntry(new ChannelPoster(bigbang2, "生活大爆炸(第二季)" ,"http://appkon.com/hdtvs/channel/bigbang2.xml" ,"http://movie.douban.com/subject/3190880/" ));
mDB.createchannelEntry(new ChannelPoster(bigbang3, "生活大爆炸(第三季)" ,"http://appkon.com/hdtvs/channel/bigbang3.xml" ,"http://movie.douban.com/subject/3990470/" ));
mDB.createchannelEntry(new ChannelPoster(bigbang4, "生活大爆炸(第四季)" ,"http://appkon.com/hdtvs/channel/bigbang4.xml" ,"http://movie.douban.com/subject/4804079/" ));
}
}catch (Exception e) {
Intent i = new Intent();
i.setClassName("com.appkon.hdtvs",
"com.appkon.hdtvs.HDtvs");
finish();
startActivity(i);
}
finally {
Intent i = new Intent();
i.setClassName("com.appkon.hdtvs",
"com.appkon.hdtvs.HDtvs");
finish();
startActivity(i);
}
}
};
splashThread.start();
}
public boolean tabIsExist(String channelS_TABLE){
boolean result = false;
if(channelS_TABLE == null){
return false;
}
Cursor cursor= ChannelDB.check();
startManagingCursor(cursor);
try {
if(cursor.moveToNext()){
int count = cursor.getInt(0);
if(count>0){
result = true;
}
}
} catch (Exception e) {
Log.e(this.toString(),"error:"+e.toString());
Intent intent = new Intent(this,HDtvs.class);
startActivity(intent);
this.finish();
}
return result;
}
}
and this is my splash.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/splash">
</LinearLayout>
Upvotes: 0
Views: 1390
Reputation: 11
first post xD hope this helps.
You need to edit the AndroidManifest.xml to include your splash activity
<activity android:name=".Splash"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Remember to set category to LAUNCHER
, and your main activity should look like this
<activity android:name=".Main"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.anibalismo.sovica.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Don´t forget to change the main´s category to DEFAULT and alse change Main action name to "com.anibalismo.sovica.MAIN"
... think you should use your package name there, but not obligatory.
Source: Youtube: thenewboston
Upvotes: 0