View source code any website
View source code any website very simple example application devlopered by edu porpers
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#a3c539">
<EditText
android:id="@+id/et1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your url"
android:textSize="14sp"
android:padding="8dp"
android:textColor="#fff"
android:textStyle="bold"
android:textColorHint="#fff"
android:layout_weight="1"
android:background="@android:color/transparent"/>
<ImageView
android:onClick="done"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_arrow_forward_black_24dp"
android:scaleType="fitCenter"/>
</LinearLayout>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webview">
</WebView>
</LinearLayout>
Example video :-
Creating the User Interface
To start, we are going to create the user interface of our Torch view sroce Application the Android device..
To start, we are going to create the user interface of our Torch view sroce Application the Android device..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#a3c539">
<EditText
android:id="@+id/et1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your url"
android:textSize="14sp"
android:padding="8dp"
android:textColor="#fff"
android:textStyle="bold"
android:textColorHint="#fff"
android:layout_weight="1"
android:background="@android:color/transparent"/>
<ImageView
android:onClick="done"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_arrow_forward_black_24dp"
android:scaleType="fitCenter"/>
</LinearLayout>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webview">
</WebView>
</LinearLayout>
Updating the Android Manifest
<uses-permission android:name="android.permission.INTERNET"/>
MainActivity.java
package neo.com.viewsourcecode;
import android.graphics.Bitmap;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
private WebView webview;
private EditText et1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview = findViewById(R.id.webview);
et1 = findViewById(R.id.et1);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDisplayZoomControls(true);
webview.getSettings().setSupportZoom(true);
webview.setWebViewClient( new WebViewClient(){
@Override
public void onPageStarted(WebView param1, String param2, Bitmap param3){
final String Url= param2;
}
@Override
public void onPageFinished(WebView param1, String param2){
final String Url= param2;
}
});
}
public void done(View view) {
if(et1.getText().toString().equals("https://") && et1.getText().toString().equals("https://")){
webview.loadUrl("view-source"+et1.getText().toString());
} else {
webview.loadUrl("view-source:https://"+et1.getText().toString());
}
}
}
0 Comments: