Create Parent Activity and pass its information to Child Activity using Intents.

Similar documents
Our First Android Application

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

Android Programs Day 5

Intents. Your first app assignment

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Android Application Development. By : Shibaji Debnath

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

<uses-permission android:name="android.permission.internet"/>

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

ANDROID PROGRAMS DAY 3


ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Android UI Development

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

Fragment Example Create the following files and test the application on emulator or device.

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android.

Starting Another Activity Preferences

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

05. RecyclerView and Styles

Tabel mysql. Kode di PHP. Config.php. Service.php

South Africa

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

ELET4133: Embedded Systems. Topic 15 Sensors

Time Picker trong Android

Basic GUI elements - exercises

TPCT s College of Engineering, Osmanabad. Laboratory Manual SDL-II. Mobile Application Development (Android) For. Third Year Students (CSE)

Fragments. Lecture 11

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Eamonn de Leastar

SD Module-1 Android Dvelopment

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

Android Apps Development for Mobile Game Lesson 5

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

User Interface Development in Android Applications

Accelerating Information Technology Innovation

Vienos veiklos būsena. Theory

Mobile Software Development for Android - I397

Introduction to Android Development

Dynamically Create Admob Banner and Interstitial Ads

COMP61242: Task /04/18

Android - JSON Parser Tutorial

Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks.

android:layout_margintop="5dp" > <EditText android:layout_width="210dp"

else if(rb2.ischecked()) {

Workshop. 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking

Database Development In Android Applications

1. Simple List. 1.1 Simple List using simple_list_item_1

Android Navigation Drawer for Sliding Menu / Sidebar

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices.

Tutorial: Setup for Android Development

PROGRAMMING APPLICATIONS DECLARATIVE GUIS

Tutorial: Setup for Android Development

M.A.D Assignment # 1

Action Bar. Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps.

Manifest.xml. Activity.java

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Android Layout Types

ANDROID USER INTERFACE

Arrays of Buttons. Inside Android

StoppUhr. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start1"


Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Meniu. Create a project:

Computer Science E-76 Building Mobile Applications

Android HelloWorld - Example. Tushar B. Kute,

COMP4521 EMBEDDED SYSTEMS SOFTWARE

Lecture 14. Android Application Development

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Data Persistence. Chapter 10

Android - Widgets Tutorial

Topics of Discussion

EMBEDDED SYSTEMS PROGRAMMING Android Services

Practical 1.ListView example

Android Application Development

Chapter 8 Positioning with Layouts

Chapter 5 Flashing Neon FrameLayout

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

使用 TensorFlow 設計矩陣乘法計算並轉移執行在 Android 上 建國科技大學資管系 饒瑞佶 2017/8

Learn about Android Content Providers and SQLite

ActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { }

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Simple Currency Converter

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

android-espresso #androidespresso

Mobila applikationer och trådlösa nät, HI1033, HT2013

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

API Guide for Gesture Recognition Engine. Version 2.0

<uses-permission android:name="android.permission.internet" />


Transcription:

Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view; import android.content.intent; import android.widget.*; public class MainActivity extends Activity { public static final String EXTRA_MESSAGE="com.example.First.MESSAGE"; public static final String EXTRA_MESSAGE1="com.example.First.MESSAGE1"; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); public boolean oncreateoptionsmenu(menu menu) { Inflate the menu; this adds items to the action bar if it is present. getmenuinflater().inflate(r.menu.main, menu); public void sendmessage(view view) { Intent intent=new Intent(this,DisplayMessageActivity.class); EditText t=(edittext)findviewbyid(r.id.message); String message=t.gettext().tostring(); EditText t1=(edittext)findviewbyid(r.id.edittext01); String message1=t1.gettext().tostring(); intent.putextra(extra_message,message); intent.putextra(extra_message1,message1); startactivity(intent); public void cleartext(view view) { EditText t=(edittext)findviewbyid(r.id.message); t.settext(""); EditText t1=(edittext)findviewbyid(r.id.edittext01); t1.settext("");

/*DisplayMessageActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.menuitem; import android.support.v4.app.navutils; import android.annotation.suppresslint; import android.annotation.targetapi; import android.os.build; import android.content.intent; import android.widget.textview; public class DisplayMessageActivity extends Activity { @SuppressLint("NewApi") protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); Intent intent=getintent(); String username=intent.getstringextra(mainactivity.extra_message); String password=intent.getstringextra(mainactivity.extra_message1); String message=""; if(username.equals("te") && password.equals("batcha")) message="login Successful!"; else message="login Unsuccessful!"; TextView t1=new TextView(this); t1.settextsize(40); t1.settext(message); setcontentview(t1); Show the Up button in the action bar. setupactionbar(); /** * Set up the {@link android.app.actionbar, if the API is available. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupactionbar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getactionbar().setdisplayhomeasupenabled(true); @ Override public boolean oncreateoptionsmenu(menu menu) { Inflate the menu; this adds items to the action bar if it is present.

getmenuinflater().inflate(r.menu.display_message, menu); @ Override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: This ID represents the Home or Up button. In the case of this activity, the Up button is shown. Use NavUtils to allow users to navigate up one level in the application structure. For more details, see the Navigation pattern on Android Design: http:developer.android.com/design/patterns/navigation.html#up-vs-back NavUtils.navigateUpFromSameTask(this); return super.onoptionsitemselected(item); /*activity_main.xml */ <LinearLayout xmlns:android="http:schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <EditText android:id="@+id/edittext01" android:layout_width="198dp" android:ems="10" android:hint="@string/to" > <requestfocus /> </EditText> <EditText android:id="@+id/message" android:layout_width="198dp" android:hint="@string/message" /> <Button android:id="@+id/send"

android:layout_width="wrap_content" android:onclick="sendmessage" android:text="@string/send" /> <Button android:id="@+id/reset" android:layout_width="wrap_content" android:onclick="cleartext" android:text="@string/reset" /></LinearLayout> /* acitivity_display_main.xml */ <RelativeLayout xmlns:android="http:schemas.android.com/apk/res/android" xmlns:tools="http:schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".displaymessageactivity" > <TextView android:layout_width="wrap_content" android:text="@string/hello_world" /> </RelativeLayout> /* Strings.xml */ <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">first</string> <string name="action_settings">settings</string> <string name="hello_world">hello world, Hello Android</string> <string name="subject">subject</string> <string name="to">to</string> <string name="message">message</string> <string name="reset">clear</string> <string name="send">send</string> <string name="title_activity_display_message">my Message</string> </resources>

********************************OUTPUT************************ Sonali K.