2009-12-27 19 views

Trả lời

40

Ghi đè onStart() - bạn nhận được thông số Intent làm thông số.

+0

bạn có thể cho một chi tiết Giải thích – Prasad

4

Để vượt qua các tính năng bổ sung:

Intent intent = new Intent(this, MyService.class); 
intent.putExtra(MyService.NAME, name); 
... 
startService(intent); 

Để lấy lại tính năng bổ sung trong dịch vụ:

public class MyService extends Service { 
    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) { 
     super.onStartCommand(intent, flags, startId); 
     String name = intent.getExtras().getString(NAME); 
     ... 
    } 
    ... 
} 
Các vấn đề liên quan