Skip to content

Commit

Permalink
Restoring code that reads the strings.xml file, merging indeed's changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowser committed Feb 25, 2009
1 parent c6d6517 commit 8e99071
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
3 changes: 1 addition & 2 deletions android/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, PhoneGap</string>
<string name="app_name">PhoneGap</string>
<string name="url">http://phonegap.com/demo2/</string>
<string name="url">file:///android_asset/index.html</string>
</resources>
25 changes: 20 additions & 5 deletions android/src/com/nitobi/phonegap/DroidGap.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* website: http://phonegap.com
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* Software), to deal in the Software without restriction, including
* Software), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
Expand All @@ -13,7 +13,7 @@
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
Expand All @@ -22,6 +22,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import java.lang.reflect.Field;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -59,9 +61,22 @@ public void onCreate(Bundle savedInstanceState) {
/* Bind the appView object to the gap class methods */
bindBrowser(appView);



appView.loadUrl("file:///android_asset/index.html");
/* Load a URI from the strings.xml file */
String uri = null;
Class<R.string> c = R.string.class;
Field f;

int i = 0;

try {
f = c.getField("url");
i = f.getInt(f);
uri = this.getResources().getString(i);
} catch (Exception e)
{
uri = "http://www.phonegap.com";
}
appView.loadUrl(uri);

}

Expand Down
5 changes: 2 additions & 3 deletions android/src/com/nitobi/phonegap/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public static final class raw {
public static final int on=0x7f040002;
}
public static final class string {
public static final int app_name=0x7f050001;
public static final int hello=0x7f050000;
public static final int url=0x7f050002;
public static final int app_name=0x7f050000;
public static final int url=0x7f050001;
}
}

0 comments on commit 8e99071

Please sign in to comment.