I am developing an android app using phonegap (cordova-2.1.0).
My MainActivity.java code is as following -
package com.app.myapp;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Problem : Whenever I start the application, it shows MainActivity window first and then show the actual HTML code. Is there any way to get rid of MainActivity and show the HTML directly?
Thanks in Advance...
Add this to your AndroidManifest application tag:
android:theme="#android:style/Theme.NoTitleBar"
Should do the trick.
Related
I am new to android studio and when i am about to start ,the error is noticed by me in the below snippet.i have recognised it by an indication in android studio.U can see below image to trace out my issue.
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Main2Activity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
}
when i go through that by clicking it shows 720 errors.What might be reason behind this and how to solve.Please help me.
http://i.stack.imgur.com/EayEp.png
This is standard practice. Your code should compile and run as is (judging by the screenshot at least)
Are you referring to the 720 errors in the actual system's class' onCreate method? That's the Android's system inner workings and you have no reason to go there right now as a beginner.
Creating a webbrowser custom!
I or WE need a custom webbrowser , so far i have a webviewer, or so it seems... i wish that it doesn't start running the current webbrowser on my Phone
so briefly
I want a custom webbrowser ...
visit most recent visited pages ...
avoid running google chrome or any other Webbrowser app on my phone
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView ourBrowser = (WebView)findViewById(R.id.wvBrowser);
ourBrowser.loadUrl("http://www.google.com");
}
}
You can use Zirco browser. It is open source and based on Webview. You can further customize it for your need.
I have a WebView app that I want to behave like this:
The user can follow any link and the new page is opened inside the same WebView, except if the target is YouTube in which case I want two possible scenarios:
Open the YouTube Android app to view the video
Open the standard browser to view the video.
My main activity is as follows:
package com.prgguru.android;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.webkit.WebView;
#SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
WebView browser;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
browser=(WebView)findViewById(R.id.webkit);
browser.getSettings().setJavaScriptEnabled(true);
browser.getSettings().setDefaultFontSize(20);
browser.loadUrl("http://exo-agency.com/funnytube/");
}
}
Thanks in advance.
I am new to PhoneGap. I am using it to deploy my website on android phone. So I created www folder in assets folder and put all my HTML, CSS an js file and written this code to call the index.html page
import org.apache.cordova.DroidGap;
import android.app.ActionBar;
import android.os.Bundle;
import android.view.Window;
public class HelloPhoneGapActivity extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Every thing is working fine but now I have to add Action Bar with close button on every page. I don't know how to do that.
Use navigator.app.exitApp(); to exit the application. Either do it on the click of a button or override the back key.
UPDATE:
Create a listener like this
document.addEventListener("backbutton", onBackClickEvent, true);
Then in the onBackClickEvent() write this
function onBackClickEvent() {
navigator.app.exitApp();
}
public class ActivityGoogleMaps extends MapActivity {// map view shows as an error
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
I try to import this:
import com.google.android.maps.MapActivity;
but when i type com. - google doesnt appear..
1- Go to Project Properties
2- From android tab, select Google API for your target platform
(for 2.2, select Google APIs-Platform 2.2 and things like that)
I think this can solve the problem
you will have to add map.jar to libs. though it is automatically added when we extends MapActivity.