Referencing default.png in Android

You must Login before you can answer or comment on any questions.

Hello,

I'm trying to make a loading screen with a progress bar that is displayed while the app is starting up. This screen will be displayed after the splash screen and before the actual start screen of the app. This loading screen is going to have the splash image as the background so it looks like the default splash screen of the app.

I'm using density specific splash image(s) in my app but somehow I can't reference the splash image in my loading screen in Android. In iPhone referencing 'default.png' works fine, but Android can't find it.

I've tried referencing 'default.png', '/images/default.png', 'background.png', '/images/background.png' but Android just can't find it.

I've tried referencing it in both a Window (as a backgroundImage):

var window = Ti.UI.createWindow({
    backgroundColor : '#ffffff',
    //backgroundImage : (Platform.isApple() ? 'default.png' : '/images/default.png'),
    fullscreen: true,
    navBarHidden: true,
    layout: 'composite',
    orientationModes : [Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT]
});
and referencing it in an ImageView:
var splashImage = Ti.UI.createImageView({
    image: 'default.png',
    top: 0, left: 0,
    width: '100%', height: '100%'
});
window.add(splashImage);

Does anybody know the trick to referencing the correct density-specific splash image in Android?

— asked 7 months ago by Esperanto XL
3 Comments
  • Oops, accidently forgot to remove the // from the code.

    — commented 7 months ago by Esperanto XL

  • do u have your ui in resources/ui/android and image in the resource/images/default.png ?

    — commented 7 months ago by Ishan Singh

  • My density specific splash images are located in /Resources/android/images/res-**dpi/default.png . Note that other density-specific images work fine.

    I'm trying to reference the splash image from /Resources/ui/common/LoadingWindow.js .

    — commented 7 months ago by Esperanto XL

2 Answers

try ../../../images/your path after images or try ../../images/your path after images

— answered 7 months ago by Ishan Singh
answer permalink
1 Comment
  • Referencing either ../images/default.png, ../../images/default.png or ../../../images/default.png all resulted in a application crash:

    [WARN][dalvikvm( 3392)] threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    [ERROR][TiApplication( 3392)] (main) [294,294] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 2.1.3,2012/10/02 16:16,15997d0
    [ERROR][TiApplication( 3392)] java.lang.NullPointerException
    [ERROR][TiApplication( 3392)]   at java.net.URI$Helper.isValidDomainName(URI.java:631)
    [ERROR][TiApplication( 3392)]   at java.net.URI$Helper.isValidHost(URI.java:595)
    [ERROR][TiApplication( 3392)]   at java.net.URI$Helper.parseAuthority(URI.java:544)
    [ERROR][TiApplication( 3392)]   at java.net.URI$Helper.parseURI(URI.java:404)
    [ERROR][TiApplication( 3392)]   at java.net.URI$Helper.access$100(URI.java:302)
    [ERROR][TiApplication( 3392)]   at java.net.URI.<init>(URI.java:87)
    [ERROR][TiApplication( 3392)]   at org.appcelerator.titanium.util.TiUrl.absoluteUrl(TiUrl.java:274)
    [ERROR][TiApplication( 3392)]   at org.appcelerator.titanium.util.TiUrl.resolve(TiUrl.java:218)
    [ERROR][TiApplication( 3392)]   at org.appcelerator.kroll.KrollProxy.resolveUrl(KrollProxy.java:977)
    [ERROR][TiApplication( 3392)]   at ti.modules.titanium.ui.TiUIActivityWindow.handleBackgroundImage(TiUIActivityWindow.java:376)
    [ERROR][TiApplication( 3392)]   at ti.modules.titanium.ui.TiUIActivityWindow.handleBackgroundImage(TiUIActivityWindow.java:370)
    [ERROR][TiApplication( 3392)]   at ti.modules.titanium.ui.TiUIActivityWindow.processProperties(TiUIActivityWindow.java:392)
    [ERROR][TiApplication( 3392)]   at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:804)
    [ERROR][TiApplication( 3392)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:307)
    [ERROR][TiApplication( 3392)]   at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:111)
    [ERROR][TiApplication( 3392)]   at android.os.Handler.dispatchMessage(Handler.java:95)
    [ERROR][TiApplication( 3392)]   at android.os.Looper.loop(Looper.java:123)
    [ERROR][TiApplication( 3392)]   at android.app.ActivityThread.main(ActivityThread.java:4627)
    [ERROR][TiApplication( 3392)]   at java.lang.reflect.Method.invokeNative(Native Method)
    [ERROR][TiApplication( 3392)]   at java.lang.reflect.Method.invoke(Method.java:521)
    [ERROR][TiApplication( 3392)]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    [ERROR][TiApplication( 3392)]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    [ERROR][TiApplication( 3392)]   at dalvik.system.NativeStart.main(Native Method)
    [ERROR][AndroidRuntime( 3392)] FATAL EXCEPTION: main
    [ERROR][AndroidRuntime( 3392)] java.lang.NullPointerException
    [ERROR][AndroidRuntime( 3392)]  at java.net.URI$Helper.isValidDomainName(URI.java:631)
    [ERROR][AndroidRuntime( 3392)]  at java.net.URI$Helper.isValidHost(URI.java:595)
    [ERROR][AndroidRuntime( 3392)]  at java.net.URI$Helper.parseAuthority(URI.java:544)
    [ERROR][AndroidRuntime( 3392)]  at java.net.URI$Helper.parseURI(URI.java:404)
    [ERROR][AndroidRuntime( 3392)]  at java.net.URI$Helper.access$100(URI.java:302)
    [ERROR][AndroidRuntime( 3392)]  at java.net.URI.<init>(URI.java:87)
    [ERROR][AndroidRuntime( 3392)]  at org.appcelerator.titanium.util.TiUrl.absoluteUrl(TiUrl.java:274)
    [ERROR][AndroidRuntime( 3392)]  at org.appcelerator.titanium.util.TiUrl.resolve(TiUrl.java:218)
    [ERROR][AndroidRuntime( 3392)]  at org.appcelerator.kroll.KrollProxy.resolveUrl(KrollProxy.java:977)
    [ERROR][AndroidRuntime( 3392)]  at ti.modules.titanium.ui.TiUIActivityWindow.handleBackgroundImage(TiUIActivityWindow.java:376)
    [ERROR][AndroidRuntime( 3392)]  at ti.modules.titanium.ui.TiUIActivityWindow.handleBackgroundImage(TiUIActivityWindow.java:370)
    [ERROR][AndroidRuntime( 3392)]  at ti.modules.titanium.ui.TiUIActivityWindow.processProperties(TiUIActivityWindow.java:392)
    [ERROR][AndroidRuntime( 3392)]  at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:804)
    [ERROR][AndroidRuntime( 3392)]  at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:307)
    [ERROR][AndroidRuntime( 3392)]  at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:111)
    [ERROR][AndroidRuntime( 3392)]  at android.os.Handler.dispatchMessage(Handler.java:95)
    [ERROR][AndroidRuntime( 3392)]  at android.os.Looper.loop(Looper.java:123)
    [ERROR][AndroidRuntime( 3392)]  at android.app.ActivityThread.main(ActivityThread.java:4627)
    [ERROR][AndroidRuntime( 3392)]  at java.lang.reflect.Method.invokeNative(Native Method)
    [ERROR][AndroidRuntime( 3392)]  at java.lang.reflect.Method.invoke(Method.java:521)
    [ERROR][AndroidRuntime( 3392)]  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    [ERROR][AndroidRuntime( 3392)]  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    [ERROR][AndroidRuntime( 3392)]  at dalvik.system.NativeStart.main(Native Method)
    [WARN][ActivityManager(   60)]   Force finishing activity nl.esperantoxl.komunikado/org.appcelerator.titanium.TiActivity
    [WARN][ActivityManager(   60)]   Force finishing activity nl.esperantoxl.komunikado/.EsperantoxlActivity
    [WARN][ActivityManager(   60)] Activity pause timeout for HistoryRecord{451b6ad0 nl.esperantoxl.komunikado/org.appcelerator.titanium.TiActivity}

    — commented 7 months ago by Esperanto XL

Currently I've worked around this issue by copying all the default.png files to background.png in the same directory.

I hope this issue can get fixed so I don't need to have double splash images in my application anymore.

Your Answer

Think you can help? Login to answer this question!