java - Error when trying to add splash screen - android app -
i'm android newbie
i following tutorial android splash screen howto, it's little outdated, anyways.
i add new layout file splash.xml
res/layout, , image drawable/mdpi, change main image mainactivity.java, ie:
setcontentview(r.layout.activity_main);
to
setcontentview(r.layout.splash);
being activity_main
name of default layout, activity_main.xml, , splash
name of other layout called splash.xml.
but application stops, says application has unfortunately stopped, , can't access it.
i don't know missing here, here's interesting code on mainactivity.java:
protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); getwindow().setformat(pixelformat.translucent); requestwindowfeature(window.feature_no_title); getwindow().setflags( windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.splash); relativelayout=(relativelayout) findviewbyid(r.id.containerimg); relativelayout.setdrawingcacheenabled(true); camerasurfaceview = (surfaceview) findviewbyid(r.id.surfaceview1); // camerasurfaceview.setlayoutparams(new framelayout.layoutparams(640, 480)); camerasurfaceholder = camerasurfaceview.getholder(); camerasurfaceholder.addcallback(this); // camerasurfaceholder.settype(surfaceholder. // surface_type_push_buffers); btncapture = (button)findviewbyid(r.id.button1); btncapture.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub camera.takepicture(camerashuttercallback, camerapicturecallbackraw, camerapicturecallbackjpeg); } }); }
my activity_main.xml
:
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <relativelayout android:id="@+id/containerimg" android:layout_width="match_parent" android:layout_height="match_parent" > <surfaceview android:id="@+id/surfaceview1" android:layout_width="1276px" android:layout_height="745px" android:layout_centerinparent="true" /> <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/surfaceview1" android:layout_alignleft="@+id/surfaceview1" android:layout_marginleft="20px" android:src="@drawable/mark3" /> </relativelayout> <button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:background="@drawable/camera" /> </framelayout>
my splash.xml
:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <imageview android:src="@drawable/splash" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaletype="fitxy"/> </linearlayout>
any ideas?
maybe should use same activity_main.xml
purposes, not sure...
thanks in advance!
edit
logcat:
3774-3774/com.kkoci.photo e/androidruntime﹕ fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{com.kkoci.photo/com.kkoci.photo.mainactivity}: java.lang.nullpointerexception @ android.app.activitythread.performlaunchactivity(activitythread.java:2245) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2295) @ android.app.activitythread.access$700(activitythread.java:150) @ android.app.activitythread$h.handlemessage(activitythread.java:1280) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:175) @ android.app.activitythread.main(activitythread.java:5279) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) @ dalvik.system.nativestart.main(native method) caused by: java.lang.nullpointerexception @ com.kkoci.photo.mainactivity.oncreate(mainactivity.java:65) @ android.app.activity.performcreate(activity.java:5283) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1097) @ android.app.activitythread.performlaunchactivity(activitythread.java:2209) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2295) @ android.app.activitythread.access$700(activitythread.java:150) @ android.app.activitythread$h.handlemessage(activitythread.java:1280) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:175) @ android.app.activitythread.main(activitythread.java:5279) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) @ dalvik.system.nativestart.main(native method)
relativelayout=(relativelayout) findviewbyid(r.id.containerimg); relativelayout.setdrawingcacheenabled(true); camerasurfaceview = (surfaceview)findviewbyid(r.id.surfaceview1);
these views present in activity_main
xml file.. when change layout file why accessing these?
Comments
Post a Comment