Thursday, 20 October 2016

Explicit Intent

Unequivocal purposes indicate the segment to begin by name (the completely qualified class name). You'll normally utilize an unequivocal plan to begin a part in your own particular application, since you know the class name of the movement or administration you need to begin. For instance, begin another action because of a client activity or begin an administration to download a document out of sight.

Syntax : -  By using Intent class
                  Intent in=new Intent(Currentclass.this,TargetActivity.class);

activity_main.xml :-

<?xml version="1.0" encoding="utf-8"?>
 android:text="call to second activity" 
 android:background="#ca4b4b" />

</LinearLayout> :-

package com.kiranapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Menu;
import android.view.MEnuItem;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

 Button entersecond;

@Override protected void onCreate(Bundle savedInstanceState) {
 entersecond.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
 Intent in=new Intent(MainActivity.this,secondactivity.class);
Note :-  

In this code i taken one activty and second activity only.

 For secondactivity.class we have to create one java class i.e under java give right click and create the class name i.e "".

 Similarly in layout i.e second_activity.xml also should create the layout.
      Shown below figure 2 i.e you enter second activity (Text View).

If we want more activities we can create " java class and xml "

Output :-

Explicit Intent
Explicit Intent fig :1

Explicit Intent
Explicit Intent fig :2

1 comment: