According to your logs, the current working directory at the time that the
file path is constructed is different.

Since the source path is relative, this produces different results.

Assuming you know where "Game 1.xwg" really is, why not construct an
absolute path to begin with?

-- Kostya

2011/6/5 eehouse <[email protected]>

> Thanks for the suggestion.  It's provided the clue that will let me
> work around the problem.  But for the record, calling
> getAbsolutePath() isn't changing the result: I still get different
> paths on the two (identical) devices:
>
> Code:
>
>        Utils.logf( "launchGame(%s)", path );
>         File file = new File( path );
>         Utils.logf( "file: %s", file.getAbsolutePath() );
>
> One log:
>
> D/XW4     (25851): [09:57:35]-1-launchGame(Game 1.xwg)
> D/XW4     (25851): [09:57:35]-1-file: /Game 1.xwg
>
> The other log:
>
> D/XW4     ( 5102): [09:56:26]-1-launchGame(Game 1.xwg)
> D/XW4     ( 5102): [09:56:26]-1-file: /data/data/
> com.lge.providers.flex/databases/Game 1.xwg
>
> It's the same if I use getCanonicalPath().
>
> Thanks,
>
> --Eric
>
> On Jun 5, 5:21 am, Kostya Vasilyev <[email protected]> wrote:
> > The path you're feeding to Uri.fromFile is not absolute.
> >
> > Make it so (by calling file.getAbsolutePath or file.getCanonicalPath) and
> > you should get consistent, predictable results.
> >
> > -- Kostya
> >
> > 2011/6/5 eehouse <[email protected]>
> >
> > > I've tracked a crash in my app that's only reproducible on one phone
> > > (that I've seen) to a strange return from Uri.fromFile().
> >
> > > I have two identical T-Mobile LG G2X devices.  They were purchased at
> > > the same time.  Software version strings in Settings/About phone are
> > > identical.  I've hard-reset both to eliminate config differences.
> > > When I run my app on one, it crashes immediately 100% of the time.
> > > Run on the other it's fine (as it is on every other device I've tested
> > > on.)
> >
> > > The function that shows the problem looks like this, after I add
> > > logging:
> >
> > >    public static void launchGame( Activity activity, String path )
> > >    {
> > >        File file = new File( path );
> > >        Utils.logf( "file: %s", file.getPath() );
> > >        Uri uri = Uri.fromFile( file );
> > >        Utils.logf( "Uri.fromFile=>%s", uri.toString() );
> > >        [...]
> > >    }
> >
> > > On the device where there's no crash the logs look like this:
> >
> > > D/XW4     ( 7107): [22:59:40]-1-file: Game 1.xwg
> > > D/XW4     ( 7107): [22:59:40]-1-Uri.fromFile=>file:///Game%201.xwg
> >
> > > while on the device that's about to crash I see this:
> >
> > > D/XW4     ( 4234): [23:00:36]-1-file: Game 1.xwg
> > > D/XW4     ( 4234): [23:00:36]-1-Uri.fromFile=>file:///data/data/
> > > com.lge.providers.flex/databases/Game%201.xwg
> >
> > > Has anybody seen this before?  Is there any chance that it's other
> > > than a weird bug in the phone itself?
> >
> > > Thanks,
> >
> > > --Eric
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to