how to Customize Webbrowser? - android

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.

Related

overrides onCreate method in android.support.v7.app.AppCompactActivity

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.

Custom Android WebView to open all links internally except YouTube links

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.

Double ActionBar appears?

this is my first app for android, I've been an iPhone dev for 3 years, it's been a change of mindset, and I still find some things odd. First I don't know if this iPhone background might be causing some troubles, but here's what I'm trying to do:
I want to implement an ActionBar with two options working like a TabBar from iOS:
What I want is that when the user selects an action, some Activity will be presented to the user.
Here's what I'm doing so far (which isn't that much):
I'm Using ActionBarSherlock, I have 3 activities: myApp, First and Second
myapp.java only creates the ActionBar elements and loads the activity_first:
package com.example.myApp;
import com.actionbarsherlock.ActionBarSherlock;
import com.actionbarsherlock.view.MenuItem;
import android.os.Bundle;
import com.actionbarsherlock.ActionBarSherlock.OnCreateOptionsMenuListener;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
public class myApp extends SherlockActivity implements OnCreateOptionsMenuListener {
ActionBarSherlock mSherlock = ActionBarSherlock.wrap(this);
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("myApp");
mSherlock.setContentView(R.layout.activity_first);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("First")
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
menu.add("Second")
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
return true;
}
}
The activities have nothing so far, apart from the generated stub:
import android.app.Activity;
import android.os.Bundle;
public class First extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
}
}
So I have 1 Question and 1 problem:
Question: Is this the correct use of an ActivityBar? I mean, should it be used to switch activities?
Problem: As you can see in the OnCreate method of myApp class, I'm loading the activity_first, It does load the activity, however it loads the ActionBar Twice, like so:
I don't get why is it being loaded twice. If I remove the line: mSherlock.setContentView(R.layout.activity_first); it loads the Bar once, obviously I need to load the activity...
Also I've assigned the NoActionBar theme to the activity_first in the graphical editor of the XML (activity_first.xml), but it doesn't work. What Can I do to load it just once.
Thank you for your valuable time.
Is this the correct use of an ActivityBar? I mean, should it be used to switch activities?
You can think of "First" and "Second" as being the equivalent of toolbar buttons in a desktop app. You are welcome to have those action bar items start up activities if you wish.
As you can see in the OnCreate method of myApp class, I'm loading the activity_first, It does load the activity, however it loads the ActionBar Twice, like so:
Delete this line:
ActionBarSherlock mSherlock = ActionBarSherlock.wrap(this);
and change mSherlock.setContentView(R.layout.activity_first); to just setContentView(R.layout.activity_first);. I believe that will clear up your problems.

Hide MainActivity window in phonegap application

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.

Adding ActionBar in HTML pages using PhoneGap in android

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();
}

Categories

Resources