Creating Basic app that opens a url

Asked

Viewed 1,770 times

1

I already touched a little on these sites that offer "free app" and some of these sites have a good feature for me!

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

I don’t think I explained it very well, but if anyone understood, could you tell me +/- how to do it?

I want to make an app based on this idea, but basic even, no tabs, no nothing! I would just like to "emulate" the site inside the app!

inserir a descrição da imagem aqui

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.