activity_main.xml
---------------------
-------------------------
Output is:
---------------
---------------------
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Google" android:id="@+id/button" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="74dp" /> </RelativeLayout>MainActivity.Java
-------------------------
package com.android.anil.implicitintent; import android.content.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import java.net.URI; public class MainActivity extends AppCompatActivity { Button googlebtn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); googlebtn=(Button)findViewById(R.id.button); googlebtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in=new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); startActivity(in); } }); } }
Go to Android
Manifest.xml and be sure to add the <uses-permission tag >
<manifest xlmns:android...>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
Output is:
---------------
No comments:
Post a Comment