Twitter Facebook Delicious Digg Stumbleupon Favorites More

Monday 19 June 2017

Intent Implicit and explicit

Intent can be bascially used to communicate between 2 activities inside the same app or to communicate between two activities in different app.

There are two types of intent 
1. Explicit Intent
2. Implicit Intent 

Implicit Intent - In implicit intent communication takes place between 2 activities of different application .

Implicit intent is basically used for starting services like
Like phonecall, sms, maps, etc 

Explicit Intent - In explicit Intent the communication takes place between 2 activities inside the same application .



implicit intant 

activity to website 

Explicit Intent

one activity to another activity of same app


IMPLICIT INTENT JAVA FILE

package com.example.viraj.blog_17_implicitintent;

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 {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button b=(Button)findViewById(R.id.id_button);
        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent=new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://android-tutorialss.blogspot.com/"));
                startActivity(intent);

            }
        });
    }
}


EXPLICIT INTENT

Intent intent= new Intent(getApplicationContext(), secondactivity.class);  

startActivity(intent);  

Share:

0 comments:

Post a Comment

Search This Blog

Popular Posts

Pages

how to make crores from 1 lakh in stock markets in 1 year

how to make crores from 1 lakh in stock markets in 1 year

Blogger Tutorials

Blogger Templates

Sample Text

Copyright © ANDROID TUTORIAL CODE | Powered by Blogger
Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com & Distributed By Protemplateslab