Skip to content

Instantly share code, notes, and snippets.

@crobertsappdeveloper
Created January 24, 2017 22:10
Show Gist options
  • Save crobertsappdeveloper/74ec5f4aa13622fa2ad892f26c510e64 to your computer and use it in GitHub Desktop.
Save crobertsappdeveloper/74ec5f4aa13622fa2ad892f26c510e64 to your computer and use it in GitHub Desktop.
This app is an example of how intent can be used in Java to send a command to the browser to run a web site.
The example web site is one that I build using Dreamweaver for a successful business.
The app is very simple and sends a command to the phone to run the browser to open and run the web site in question.
You need to create a new project and name it IntentWebview for this to work and paste the code in the next window to MainActivity.java
If any red is highlighted in the window below this can be ignored as the app runs fine on my version of Android Studio and on my smartphone.
package com.example.android.intentwebview;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class IntentTest extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intent_test);
String url = "http://www.grindlebrookfarm.co.uk/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment