Intent Of Example in android Tutorial - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
IntentOfExample in android Toutorial

Intent Of Example in android Tutorial

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<Button
    android:id="@+id/button"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onClick="event"
    android:textSize="30dp"
    android:text="Open Map"
    android:layout_marginBottom="15dp"/>

    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        android:onClick="event"
        android:layout_below="@+id/button"
        android:text="Open Website"
        android:layout_marginBottom="15dp"/>


    <Button
        android:id="@+id/button3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        android:layout_below="@+id/button2"
        android:text="Open Whatsapp"
        android:onClick="event"
        android:layout_marginBottom="15dp"/>

    <Button
        android:id="@+id/button4"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        android:layout_below="@+id/button3"
        android:text="FeedBack"
        android:onClick="event"
        android:layout_marginBottom="15dp"/>

    <Button
        android:id="@+id/button5"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        android:layout_below="@+id/button4"
        android:text="Aptron tutorial"
        android:onClick="event"
        android:layout_marginBottom="15dp"/>

    <Button
        android:id="@+id/button6"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        android:layout_below="@+id/button5"
        android:text="Facebook Apps"
        android:onClick="event"
        android:layout_marginBottom="15dp"/>
</RelativeLayout>
MainActivity.java
package com.example.intentuseapps;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void event (View view)

    {
        Intent intent;

        switch (view.getId())
        {
            case R.id.button:
                intent=new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("https://www.google.com/maps/@28.5911665,77.2969092,14z"));
                Intent chooser= intent.createChooser(intent,"open map");
                startActivity(chooser);
                 break;

            case R.id.button2:
                intent=new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://aptronnoida.in/"));
                 chooser= intent.createChooser(intent,"open Website");
                startActivity(chooser);
                break;
            case R.id.button3:

                intent=new Intent(Intent.ACTION_SEND);
                intent.setData(Uri.parse("Vote for bjp!!!!"));
                intent.setPackage("com.whatsapp");
                intent.setType("Text/plain");
                startActivity(intent);
                  break;
            case R.id.button4:
                intent=new Intent(Intent.ACTION_SEND);
                String[] to={"hr@aptronindia.in","sk405044@gmail.com","rajindia@gmail"};
                intent.putExtra(Intent.EXTRA_EMAIL,to);
                String[] ccEmail={"sk405045@gmail.com"};
                intent.putExtra(Intent.EXTRA_CC,ccEmail);
                intent.putExtra(Intent.EXTRA_SUBJECT,"Abhishek Sir feedback");
                intent.putExtra(Intent.EXTRA_TEXT,"Abishek is best");
                intent.setType("text/plain");
                chooser=Intent.createChooser(intent,"open feedback");
                startActivity(chooser);

                break;
            case R.id.button5:
                break;
            case R.id.button6:
                break;
        }
    }
}
Note: click on the open map then will be open map and next open 
website as like aptron then same performance output open website.
       
 


About EasyToCode

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.