Android Training in India

Passing data between activities in Android

Objective :

  • Passing data between activities in Android
  • Passing multiple data between activities in Android
  • Passing array between activities in Android
  • Passing ArrayList between activities in Android
  • Passing ArrayList to another activity in Android
  • Sending data via Intent in Android
  • Sending multiple data via Intent in Android
  • Sending array between activities in Android
  • Sending ArrayList between activities in Android
  • Sending ArrayList to another activity in Android
  • Sending data via Intent and Bundle in Android
  • Sending multiple data via Intent and Bundle in Android
  • Passing array between activities in Android using Intent and Bundle
  • How to pass array to another activity in Android?
  • How to pass array between activities in Android?
  • How to pass data to another activity in Android?
  • How to pass data to activity in Android?
  • How to pass data to between activities in Android?
  • How to pass ArrayList to another activity in Android?
  • How to pass ArrayList between activities in Android?

 

Code for passing data between activities in Android :

ActivityOne.java

[sourcecode lang=”java”]

String value = "Hello!";
Intent in = new Intent(this,ActivityTwo.class);
in.putExtra("Key", value);
startActivity(in);

[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]

Bundle bundle = getIntent().getExtras();
String valueReceived = bundle .getString("Key");

[/sourcecode]

 

Code for passing multiple data or values between activities in Android :

Method 1 : Using Intent to pass data and Bundle to extract data between activities in Android

ActivityOne.java

[sourcecode lang=”java”]

String value1 = "Hello!";
String value2 = "Hi!";
Intent in = new Intent(this,ActivityTwo.class);
in.putExtra("Key1", value1);
in.putExtra("Key2", value2);
startActivity(in);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String valueReceived1 = bundle .getString("Key1");
String valueReceived2 = bundle .getString("Key2");
[/sourcecode]

 

Method 2 : Using Bundle to pass and to extract data between activities in Android

ActivityOne.java

[sourcecode lang=”java”]

String value1 = "Hello!";
String value2 = "Hi!";
Intent in = new Intent(this,ActivityTwo.class);
Bundle bundle = new Bundle();
bundle.putString("Key1", value1);
bundle.putString("Key2", value2);
in.putExtras(bundle);
startActivity(in);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String valueReceived1 = bundle .getString("Key1");
String valueReceived2 = bundle .getString("Key2");
[/sourcecode]

 

Code for passing array between activities in Android :

ActivityOne.java

[sourcecode lang=”java”]
String[] array = new String[]{"Item1", "Item2", "item3", "Item4", "item5"};
Intent in = new Intent(this,ActivityTwo.class);
Bundle bundle = new Bundle();
bundle.putStringArray("MyArray", array);
in.putExtras(bundle);
startActivity(in);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String arrayReceived[] = bundle.getStringArray("MyArray");
[/sourcecode]

 

Code for passing ArrayList between activities in Android :

ActivityOne.java

[sourcecode lang=”java”]
ArrayList<String> array = new ArrayList<String>();
array.add("Hello");
array.add("Hi");
array.add("Bye");
Intent intent = new Intent(this, ActivityTwo.class);
intent.putExtra("array_list", array);
startActivity(intent);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
ArrayList<String> array = (ArrayList<String>) bundle.getStringArrayList("array_list");
[/sourcecode]


Have fun with Intent.

LightMeUp – Flashlight Application for Android

LightMeUp – Flashlight Application for Android

It is a small application which uses the Camera Flash to enlighten and which may also help you in searching something in dark. The best part is it works in a single click on  your Android phone with or without flash. If your phone does not have flash, it will set brightness of your phone to maximum, as soon as you close application it will set brightness back to original.

This application was developed as a part of Android Training we provide at AnCyber, Pune (India).


Get it on Google Play

Go, download and get enlightened.

Android Emulator Keyboard Shortcuts

Objectives:

  • How to use Emulator for Android?
  • What are the Android Emulator Shortcuts?
  • What are the Android Emulator Keyboards Shortcuts?
  • What are the Keyboard Shortcuts for Android Emulator?
  • How to use Android Emulator from Keyboard?

Keyboard shortcuts for Android Emulator :

Emulator Key / Function

Keyboard Shortcut

Home Home
Menu F2 or Page-up
Star Shift + F2 or Page-down
Back Esc
Call / Dial F3
Hang-up / End Call / Lock Screen F4
Search F5
Power F7
Volume-up Keypad ‘+’ or Ctrl + 5
Volume-down Keypad ‘-’ or Ctrl + 6
Camera Ctrl + Keypad 5 or Ctrl + F3
Previous Layout Orientation Keypad 7 or Ctrl + F11
Next Layout Orientation Keypad 9 or Ctrl + F12
Toggle Cell Networking ON/OFF F8
Toggle Code Profiling F9 (only with -trace startup option)
Toggle Full screen Mode Alt + Enter or Alt + Return
Toggle Trackball Mode F6
Enter Trackball Mode Temporarily Delete
DPad Left Keypad 4
DPad Right Keypad 6
DPad Up Keypad 8
DPad Down Keypad 2
DPad Center Keypad 5
Increase Onion Alpha Keypad * (Multiply or Star)
Decrease Onion Alpha Keypad / (Divide)

Enjoy coding.

Source : Android

Want to Learn Android?

Learn Android in Nagpur

Great news for Nagpur people, now you don’t need to go anywhere else & can learn, explore Android.

Sharda Infotech, one of the leading IT firm who is into Corporate Training since 2006 now offers Android Application Development Training, also offering jobs after completing the training depending on the performance of the candidate since Sharda Infotech is also in development from the same time & now has started Android Application Development too.

For more details mail us at training@shardainfotech.com or call us on 091 – 9766210353

If you are interested in starting your own business or franchise, write to us at franchise@shardainfotech.com or call us on 091 – 9766210353