Android Application Development Cookbook: 93 Recipes for Building Winning Apps



Download 32,34 Mb.
Pdf ko'rish
bet23/56
Sana26.02.2022
Hajmi32,34 Mb.
#470540
1   ...   19   20   21   22   23   24   25   26   ...   56
Bog'liq
Android Application Development Cookbook

10

ChAPter 1
Android FundAmentAls
code is the number that you earlier passed to the 
startActivityForResult()
method, which is 1 
in this example: 
//---start the activity to get a result back---
startActivityForResult(i, 1);
You can also check the result code to see if it is 
RESULT_OK
:
package net.learn2develop.passingdata;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClick(View view) {
Intent i = new 
Intent("net.learn2develop.SecondActivity");
//---use putExtra() to add new key/value pairs---
i.putExtra("str1", "This is a string");
i.putExtra("age1", 25);
//---use a Bundle object to add new key/values 
// pairs---
Bundle extras = new Bundle();
extras.putString("str2", "This is another string");
extras.putInt("age2", 35);
//---attach the Bundle object to the Intent object---
i.putExtras(extras);
//---start the activity to get a result back---
startActivityForResult(i, 1);
}
public void onActivityResult(int requestCode, 
int resultCode, Intent data)
{
//---check if the request code is 1---
if (requestCode == 1) {
//---if the result is OK--- 
if (resultCode == RESULT_OK) {
www.it-ebooks.info


 
Recipe 1.3 passing objects Between Activities

11
//---get the result using getIntExtra()---

Download 32,34 Mb.

Do'stlaringiz bilan baham:
1   ...   19   20   21   22   23   24   25   26   ...   56




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish