Android Application Development Cookbook: 93 Recipes for Building Winning Apps



Download 32,34 Mb.
Pdf ko'rish
bet36/56
Sana26.02.2022
Hajmi32,34 Mb.
#470540
1   ...   32   33   34   35   36   37   38   39   ...   56
Bog'liq
Android Application Development Cookbook

Figure 1-11 
Figure 1-12 
www.it-ebooks.info


28

ChAPter 1
Android FundAmentAls
If you selected Gmail, the data you set in the 
Intent
object will then be sent as an e-mail (see 
Figure 1-13).
If you selected Twitter (assuming you have Twitter installed on your device), the data you set in the 
Intent
object will then be sent as a tweet (see Figure 1-14).
Figure 1-13 
sending Binary content
If you have some images in your 
drawable
folders, you can also send them to other applications 
using the following code snippet:
//---sending binary content---
Uri uriToImage = 
Uri.parse(
"android.resource://net.learn2develop.CallingApps/drawable/" + 
Integer.toString(R.drawable.android));
Figure 1-14 
www.it-ebooks.info


 
Recipe 1.7 calling Built-in Apps

29
Intent i = new Intent(android.content.Intent.ACTION_SEND);
i.setType("image/jpeg");
i.putExtra(Intent.EXTRA_STREAM, uriToImage);
i.putExtra(Intent.EXTRA_TEXT, "Text...");
startActivity(Intent.createChooser(i, "Apps that can respond to this"));
The preceding code assumes that you have a file named 
android.jpg
located in one of the 
drawable
folders in your project (see Figure 1-15). You set the image type to 
image/jpeg
and then use the 
putExtra()
method to put the image into the 
Intent
object.
If you send the data to Twitter, the image will be used by Twitter as part of your tweet (see 
Figure 1-16).
To send multiple images, you can use the following code snippet:
import java.util.ArrayList;
...
...
Uri uriToImage1 = 
Uri.parse(
"android.resource://net.learn2develop.CallingApps/drawable/" + 
Integer.toString(R.drawable.android));
Uri uriToImage2 = 
Uri.parse(
"android.resource://net.learn2develop.CallingApps/drawable/" + 
Integer.toString(R.drawable.google));
ArrayList urisToImages = new ArrayList();
urisToImages.add(uriToImage1); 
urisToImages.add(uriToImage2);

Download 32,34 Mb.

Do'stlaringiz bilan baham:
1   ...   32   33   34   35   36   37   38   39   ...   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