Android getting Black Screen when Switching from SplashActivity to AnotherActivity -
i'm facing problem when moving splashscreen
activity anotheractivity
. problem i'm getting blackscreen
after splashscreen
disappears , before mainactivity
screen loads.
does have suggestions?
here code:
public class splash extends activity{ public list<saxmessage> torimsg = new arraylist<saxmessage>(); static final int dialog_error_connection = 1; static final int dialog_error_connection2 = 2; static final int dialog_error_connection3 = 3; boolean connected; string dialogmessage; context context; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); splashhandler mhandler = new splashhandler(); setcontentview(r.layout.splash); context=getapplicationcontext(); connected=isonline(getapplicationcontext()); log.d("connection","connection:"+connected); // create message object message msg = new message(); //assign unique code message. //later, code used identify message in handler class. msg.what = 0; // send message delay of 3 seconds(3000 = 3 sec). mhandler.sendmessagedelayed(msg, 1000); } //oncreate private boolean isonline(context conn) { connectivitymanager cm = (connectivitymanager)conn. getsystemservice(context.connectivity_service); networkinfo networkinfo = cm.getactivenetworkinfo(); if (networkinfo != null && networkinfo.isavailable() && networkinfo.isconnected()) { return true; } return false; } @override protected dialog oncreatedialog(int id) { dialog dialog = null; switch (id) { case dialog_error_connection: alertdialog.builder errordialog = new alertdialog.builder(this); errordialog.settitle("error"); errordialog.setmessage(dialogmessage); errordialog.setneutralbutton("retry", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.dismiss(); torimsg.clear(); new downloadlocalxmltask().execute(); } }); alertdialog erroralert = errordialog.create(); return erroralert; case dialog_error_connection2: alertdialog.builder errordialog1 = new alertdialog.builder(this); errordialog1.settitle("error"); errordialog1.setmessage("no internet connection."); errordialog1.setneutralbutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.dismiss(); splash.this.finish(); } }); alertdialog erroralert1 = errordialog1.create(); return erroralert1; case dialog_error_connection3: alertdialog.builder errordialog2 = new alertdialog.builder(this); errordialog2.settitle("error"); errordialog2.setmessage(dialogmessage); errordialog2.setneutralbutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.dismiss(); splash.this.finish(); } }); alertdialog erroralert2 = errordialog2.create(); return erroralert2; default: break; } return dialog; } private class downloadxmltask extends asynctask<string, void, list<saxmessage>>{ @override protected list<saxmessage> doinbackground(string... urls) { try{ saxparserfactory saxparserfactory= saxparserfactory.newinstance(); saxparser saxparser = saxparserfactory.newsaxparser(); xmlreader xr = saxparser.getxmlreader(); url sourceurl = new url ("http://toucheradio.com/toneradio/android/torilite/toriplaylist.xml"); rsshandler handler = new rsshandler(); xr.setcontenthandler(handler); xr.parse(new inputsource(sourceurl.openstream())); torimsg= handler.getmessages(); torimsg.remove(0); return torimsg; } catch(unknownhostexception e) { showmydialog(e.getmessage()); return null; } catch(saxparseexception se) { showmydialog(se.getmessage()); return null; } catch (exception e) { showmydialog(e.getmessage()); return null; } } @override protected void onpostexecute(list<saxmessage> result) { if(result==null) { showdialog(dialog_error_connection); } else { intent intent= new intent(splash.this,toriltactivity.class); bundle b=new bundle(); b.putparcelablearraylist("torimsg", (arraylist<? extends parcelable>) torimsg); intent.putextras(b); startactivity(intent); // finish current activity splash.this.finish(); } } } private void showmydialog(string b) { splash.this.dialogmessage=b; } private class splashhandler extends handler { //this method used handle received messages public void handlemessage(message msg) { // switch identify message code switch (msg.what) { default: case 0: super.handlemessage(msg); if(connected==false) { showdialog(dialog_error_connection2); } else { new downloadxmltask().execute(); } } } } }
update:
public void oncreate(bundle savedinstancestate) { log.i("hs1", "oncreate"); super.oncreate(savedinstancestate); setcontentview(r.layout.main); bundle recddata = getintent().getextras(); messages = recddata.getparcelablearraylist("torimsg"); //new gethtmldataaync().execute(); albumadapter=new lazyadapter(toriltactivity.this, messages); this.setlistadapter(albumadapter); bindtoservice(); //contentlist.setfastscrollenabled(true); buttonmethode(); adwhirlmanager.setconfigexpiretimeout(1000 * 60 * 1); adwhirltargeting.setage(23); adwhirltargeting.setgender(adwhirltargeting.gender.male); adwhirltargeting.setkeywords("online games gaming"); adwhirltargeting.setpostalcode("94123"); adwhirltargeting.settestmode(false); adwhirllayout adwhirllayout = new adwhirllayout(this,"ce9849662b9844468e942e4e3de6e2c8"); relativelayout.layoutparams layoutparams = new relativelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content); layoutparams.addrule(relativelayout.center_horizontal); layout = (linearlayout)findviewbyid(r.id.linearlayout01); layout.setgravity(gravity.center_horizontal); layout.addview(adwhirllayout, layoutparams); layout.invalidate(); this.facebookconnector = new facebookconnector(facebook_appid, this, getapplicationcontext(), new string[] { facebook_permission }); }
add anotheractivity androidmanifest.xml
add these 2 lines in androidmanifest.xml
<activity android : label ="@string/app_name" android:name=".anotheractivity" </activity>
Comments
Post a Comment