Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 6

Lp trnh Android

Hng dn xy dng
Intent gi n cc
ng dng ca h
iu hnh
Bi
35

Ths. Trn Duy Thanh duythanhcse@gmail.com 0987773061 http://duythanhcse.wordpress.com

Lp trnh Android

Ni dung bi hc

S dng Implicit Intent : Nhn tin,


gi in thoi
p dng pendingintent lng nghe
kt qu trng thi tin nhn

Ths. Trn Duy Thanh duythanhcse@gmail.com 0987773061 http://duythanhcse.wordpress.com

Lp trnh Android

Uri uri=Uri.parse("tel:"+selectedContact.getPhone());
Intent i=new Intent(Intent.ACTION_CALL, uri);
startActivity(i);
finalSmsManagersms=SmsManager.getDefault();
sms.sendTextMessage(0987773061,null,Helloteoteo!,null,null);

Ths. Trn Duy Thanh duythanhcse@gmail.com 0987773061 http://duythanhcse.wordpress.com

Lp trnh Android

public void sendSms(MyContact c)


{
//ly mc nh SmsManager
final SmsManager sms = SmsManager.getDefault();
Intent msgSent = new Intent("ACTION_MSG_SENT");
//Khai bo pendingintent kim tra kt qu
final PendingIntent pendingMsgSent =
PendingIntent.getBroadcast(this, 0, msgSent, 0);
registerReceiver(new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
int result = getResultCode();
String msg="Send OK";
if (result != Activity.RESULT_OK) {
msg="Send failed";
}
Toast.makeText(MySMSActivity.this, msg,
Toast.LENGTH_LONG).show();
}
}, new IntentFilter("ACTION_MSG_SENT"));
//Gi hm gi tin nhn i
sms.sendTextMessage(c.getPhone(), null, editContent.getText()+"",
pendingMsgSent, null);
finish();
Ths. Trn Duy Thanh
duythanhcse@gmail.com 0987773061 http://duythanhcse.wordpress.com

Lp trnh Android

Nhp s
phone:
0987773061
Ni dung tin
nhn:
Cho ng
ng cn khe
ch
Quay
Gi
s
lun

Gi
tin

Ths. Trn Duy Thanh duythanhcse@gmail.com 0987773061 http://duythanhcse.wordpress.com

Lp trnh Android

END
Ths. Trn Duy Thanh duythanhcse@gmail.com 0987773061 http://duythanhcse.wordpress.com

You might also like