[ Version. 1 ]

<service android:name="MyService" >

<intent-filter>

<action android:name="com.x.y.DOWNLOAD_DATA" />

<action android:name="com.x.y.UPLOAD_DATA" />

</intent-filter>

</service>

 

public class MyService extends IntentService {

public MyService() {

super("MyService");

}

@Override protected void onHandleIntent(Intent intent) {

if(intent.getAction().equals("com.x.y.DOWNLOAD_DATA"){ //download data here }

else if(intent.getAction().equals("com.x.y.UPLOAD_DATA"){ // upload data here } }

}

 

[ Version. 2 ]

<service android:name=".MokoService">

<intent-filter>

<action android:name="com.moko.hello.START_MUSIC" />

<category android:name="android.intent.category.DEFAULT" />

</intent-filter>

</service>

 

startService(new Intent ("com.moko.hello.START_MUSIC"));

 

 

 

 

arrow
arrow
    全站熱搜

    小彬彬 發表在 痞客邦 留言(0) 人氣()