mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
DroidGap.java changed to support demo2 inclusion
This commit is contained in:
parent
6448e16d82
commit
799ce988d5
@ -21,14 +21,13 @@ package com.nitobi.phonegap;
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
@ -44,6 +43,9 @@ public class DroidGap extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
appView = (WebView) findViewById(R.id.appView);
|
||||
@ -57,47 +59,13 @@ public class DroidGap extends Activity {
|
||||
/* Bind the appView object to the gap class methods */
|
||||
bindBrowser(appView);
|
||||
|
||||
/* 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);
|
||||
appView.loadUrl("file:///android_asset/index.html");
|
||||
|
||||
}
|
||||
|
||||
protected void loadFile(WebView appView){
|
||||
try {
|
||||
InputStream is = getAssets().open("index.html");
|
||||
|
||||
int size = is.available();
|
||||
|
||||
// Read the entire asset into a local byte buffer.
|
||||
byte[] buffer = new byte[size];
|
||||
is.read(buffer);
|
||||
is.close();
|
||||
|
||||
// Convert the buffer into a Java string.
|
||||
String text = new String(buffer);
|
||||
|
||||
// Load the local file into the webview
|
||||
appView.loadData(text, "text/html", "UTF-8");
|
||||
|
||||
} catch (IOException e) {
|
||||
// Should never happen!
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void bindBrowser(WebView appView)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user