Android Application Development Cookbook: 93 Recipes for Building Winning Apps



Download 32,34 Mb.
Pdf ko'rish
bet31/56
Sana26.02.2022
Hajmi32,34 Mb.
#470540
1   ...   27   28   29   30   31   32   33   34   ...   56
Bog'liq
Android Application Development Cookbook

“android.permission.INTERNET”)
;
Aborting a Broadcast
When broadcasts are sent using the 
sendOrderedBroadcast()
method, broadcast receivers are 
called in the order of the priorities defined. When a broadcast receiver of higher priority receives 
the broadcast, it will handle that and the broadcast will be passed to the next broadcast receiver in 
line. In some scenarios, you might want to handle the broadcast and stop the broadcast from being 
propagated to the next receiver. To do that, you can use the 
abortBroadcast()
method:
package net.learn2develop.UsingBroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class MySecondBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent i) {
Toast.makeText(context, 
"Received broadcast in MySecondBroadcastReceiver; " +
"value received: " + i.getStringExtra("key"),
Toast.LENGTH_LONG).show();
//---abort the broadcast----
abortBroadcast();
}
}
In the preceding code snippet, the 
MySecondBroadcastReceiver
class aborts the broadcast after 
receiving it. Once it aborts the broadcast, other receivers who are waiting in line will not be able
to receive it.
note
In order to call the 
abortBroadcast()
 method to abort a broadcast, you 
need to send the broadcast using the 
sendOrderedBroadcast()
 method. Using 
the 
sendBroadcast()
 method has no effect on the priority and will not cause a 
broadcast to be aborted. 
www.it-ebooks.info


 
Recipe 1.6 Auto-launching Your Application at Boot Time


Download 32,34 Mb.

Do'stlaringiz bilan baham:
1   ...   27   28   29   30   31   32   33   34   ...   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