Android Activity → Android Data Parsing – String,Integer,Boolean – Activity To Activity – Camposha

Android Activity

Android Activity

Android Data Parsing – String,Integer,Boolean – Activity To Activity

Most android applications, atleast serious ones, comprise more than one activity. Activities in android User interface units. We need a way of then passing data from one activity to another.Thats this lessons aim. The aim is to see how to pass Strings,Integers and Booleans, primitive data types from one activity to another using Intent.Here’s the thing :

  • Pass integers,booleans and string from one activity to another.
  • The booleans shall be represented in a checkbox,the string in an edittext while the integer also in an edittext.
  • The user enters them in our MainActivity,we pass them via intent, and show them in second activity.
  • We use intents.

Android Pass String Integer and Boolean from Activity to another

Create/Download Project

  • Download the project above.
  • You’ll get a zipped file,extract it.
  • Open the Android Studio.
  • Now close, already open project
  • From the Menu bar click on File >New> Import Project
  • Now Choose a Destination Folder, from where you want to import project.
  • Choose an Android Project.
  • Now Click on “OK“.
  • Done, your done importing the project,now edit it.

Our Layouts

ContentMain.xml

  • Our MainActivity’s layout.
  • Add Checkbox to show boolean values and edittexts to show integer and string.
  • User enters these values at runtime.

ActivitySecond.xml

  • Our SecondActivity’s layout.
  • Add Checkbox to show boolean values and edittexts to show integer and string.

Our Classes

MainActivity class

  • Launcher activity.
  • We pack data into an intent and pass them to Second activity from here.

SecondActivity class

  • This activity unpacks the data sent by intent from MainActivity.
  • It then displays them in their respective views.

More Resources:

Resource Link
GitHub Browse Browse
GitHub Download Link Download

Oclemy,Cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *

X