info@thistimebd.com

Thursday 21st of November 07:25:11pm

Send Date another android app source code

Main_Activity.java

-------------------

package com.sam.web.senddataanother;


import android.content.Intent;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;


public class MainActivity extends AppCompatActivity {

    private Button button;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);


        button=(Button) findViewById(R.id.buttonId);

        button.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Intent intent=new Intent(MainActivity.this,ProfileActivity.class);

                intent.putExtra("tag","Bangladesh is may motherland");

                startActivity(intent);

            }

        });

    }

}

======================================================================

activity_main.xml

--------------------


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout 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"

    android:gravity="center"

    tools:context="com.sam.web.senddataanother.MainActivity">


    <Button

        android:id="@+id/buttonId"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="@string/button_name"

        android:textSize="20sp"

        android:textStyle="bold"

        />




</LinearLayout>

===========================================================================

string.xml

----------


<resources>

    <string name="app_name">SendDataAnother</string>

    <string name="button_name">Bangladesh</string>

</resources>

===========================================================================

profile_activity.java

------------------------


package com.sam.web.senddataanother;


import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.widget.TextView;


public class ProfileActivity extends AppCompatActivity {

    private TextView textView;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_profile);


        textView=(TextView)findViewById(R.id.textViewId);


        Bundle bundle=getIntent().getExtras();


        if(bundle!=null){

          String value=  bundle.getString("tag");

          textView.setText(value);


        }

    }



}

============================================================================

activity_profile.xml

--------------------



<?xml version="1.0" encoding="utf-8"?>

<LinearLayout 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"

    android:gravity="center"

    android:background="#22e9ff"

    tools:context="com.sam.web.senddataanother.ProfileActivity">


    <TextView

        android:id="@+id/textViewId"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:textSize="20sp"

        android:textStyle="bold"

        />


</LinearLayout>