Understood Intent doesn't specify the segment. In such case, plan
gives data of accessible parts gave by the framework that will be
summoned. It does not require multiple screens.
Syntax : - By using Intent class
Intent in=new
Intent(Intent.Action_view,Url.parse("http://androiddevelopersstudio.blogspot.in"));
startActivity(in);
activity_main.xml :-
MainActivity.java :-
Output :-
Syntax : - By using Intent class
Intent in=new
Intent(Intent.Action_view,Url.parse("http://androiddevelopersstudio.blogspot.in"));
startActivity(in);
activity_main.xml :-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:orientation="vertical"
tools:context="com.kiranapp.MainActivity"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android developers studio"
android:layout_marginTop="29dp"
android:id="@+id/button"
android:layout_gravity="center_horizontal" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Facebook"
android:id="@+id/button2"
android:layout_marginTop="20dp"
android:layout_gravity="center_horizontal" /> </LinearLayout>
MainActivity.java :-
package com.kiranapp; import android.content.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button androidbtn,fbbtn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); androidbtn=(Button)findViewById(R.id.button); fbbtn=(Button)findViewById(R.id.button2); androidbtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Implicit Intent Using Intent Class
Intent in=new Intent(Intent.ACTION_VIEW,Uri.parse("http://androiddevelopersstudio.blogspot.in")); startActivity(in); } }); fbbtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.facebook.com")); startActivity(intent); } }); } }
Output :-
Implicit Intent fig :1 |
Implicit Intent fig:2 |
Implicit Intent fig :3 |
No comments:
Post a Comment