Creating Basic app that opens a url

1

I've already moved a little on those sites that offer "free app" and some of these sites have a good resource for me!

They create an app that works with a specific url, as if the app were just a "locked" browser on a specific site!

I think I did not explain very well, but if anyone understood, could you tell me +/- how do you do that?

I want to make an app based on this idea, even basic, without tabs, with nothing! I would just like to "emulate" the site within the app!

    
asked by anonymous 04.08.2015 / 07:20

1 answer

1

You can create a WebView

MainActivity.java

package com.mkyong.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

    private Button button;

    public void onCreate(Bundle savedInstanceState) {
        final Context context = this;

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        button = (Button) findViewById(R.id.buttonUrl);

        button.setOnClickListener(new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            Intent intent = new Intent(context, WebViewActivity.class);
            startActivity(intent);
          }

        });

    }

}

WebViewActivity.java

package com.mkyong.android;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView) findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://www.google.com");

    }

}

Source and examples

    
26.09.2015 / 15:25