導航:首頁 > 操作系統 > android服務列表

android服務列表

發布時間:2022-12-22 09:11:41

A. android 獲取系統運行的服務

參數為最大返回數目。
這個值一般填大一點就沒問題了,直接給個100。我們沒辦法直接得到那個值。
不用擔心萬一不夠一百怎麼辦
amanager.getRunningServices(100)他返回的是個LIST集合,你只有20個服務list.size()顯示出來也就是20.對你沒任何影響。
當然萬一大於100肯定是顯示不全的。這個無法去避免,我們只能盡可能把這個值稍微填大一點。
但是手機不可能附帶大於100的服務。現在的手機肯定帶不了。有100個服務估計直接死機。

B. 什麼是android的四大組件

Android四大組件有Activity,Service服務,Content Provider內容提供,BroadcastReceiver廣播接收器。

Android應用程序由一些零散的有聯系的組件組成,通過一個工程manifest綁定在一起。在manifest中,描述了每一個組件以及組件的作用,其中有6個組件,它們是Android應用程序的基石

(2)android服務列表擴展閱讀

Activities(活動)

應用程序的顯示層。每一個畫面對應於你的應用程序,將會是Activity類的擴展。Activity使用Views去構建UI來顯示信息和響應用戶的行為。就桌面開發而言,一個Activity相當於一張Form。

Services(服務)

Android應用程序中不可見的「工人」。 Service組件運行時不可見,但它負責更新的數據源和可見的Activity,以及觸發通知。它們常用來執行一些需要持續運行的處理,當你的 Activity已經不處於激活狀態或不可見。

Content(內容)

提供共享的數據存儲。Content Provider(內容提供器)用來管理和共享應用程序的資料庫。在應用程序間,Content Provider是共享數據的首選方式。

Broadcast Receivers(廣播接收器)

Intent廣播的「消費者」。通過創建和注冊一個Broadcast Receiver,應用程序可以監聽符合特定條件的廣播的Intent。Broadcast Receiver 會自動的啟動你的Android應用程序去響應新來的Intent。Broadcast Receiver是事件驅動程序的理想手段。

參考資料來源:網路-Android組件

C. 怎麼獲取android系統服務,如Uri,intent參數等,或者說去哪裡查看

android系統服務,如Uri,intent參數
可以在Intent中指定程序要執行的動作(比如:view,edit,dial),以及程序執行到該動作時所需要的資料。都指定好後,只要調用startActivity(),Android系統會自動尋找最符合你指定要求的應用程序,並執行該程序。

★intent大全:

1.從google搜索內容

Intent intent = new Intent();

intent.setAction(Intent.ACTION_WEB_SEARCH);

intent.putExtra(SearchManager.QUERY,"searchString")

startActivity(intent);

2.瀏覽網頁

Uri uri =Uri.parse("htt。。。。。。。。om");

Intent it = new Intent(Intent.ACTION_VIEW,uri);

startActivity(it);

3.顯示地圖

Uri uri = Uri.parse("geo:38.899533,-77.036476");

Intent it = newIntent(Intent.Action_VIEW,uri);

startActivity(it);

4.路徑規劃

Uri uri =Uri.parse("http。。。。。。。。。。/maps?
f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");

Intent it = newIntent(Intent.ACTION_VIEW,URI);

startActivity(it);

5.撥打電話

Uri uri =Uri.parse("tel:xxxxxx");

Intent it = new Intent(Intent.ACTION_DIAL,uri);

startActivity(it);

6.調用發簡訊的程序

Intent it = newIntent(Intent.ACTION_VIEW);

it.putExtra("sms_body", "TheSMS text");

it.setType("vnd.android-dir/mms-sms");

startActivity(it);

7.發送簡訊

Uri uri =Uri.parse("smsto:0800000123");

Intent it = newIntent(Intent.ACTION_SENDTO, uri);

it.putExtra("sms_body", "TheSMS text");

startActivity(it);

String body="this is sms demo";

Intent mmsintent = newIntent(Intent.ACTION_SENDTO, Uri.fromParts("smsto",
number, null));

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY,body);

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE,true);

mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT,true);

startActivity(mmsintent);

8.發送彩信

Uri uri =Uri.parse("content://media/external/images/media/23");

Intent it = newIntent(Intent.ACTION_SEND);

it.putExtra("sms_body","some text");

it.putExtra(Intent.EXTRA_STREAM, uri);

it.setType("image/png");

startActivity(it);

StringBuilder sb = new StringBuilder();

sb.append("file://");

sb.append(fd.getAbsoluteFile());

Intent intent = newIntent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto",
number, null));

// Below extra datas are all optional.

intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT,subject);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY,body);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI,sb.toString());

intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE,composeMode);

intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT,exitOnSent);

startActivity(intent);

9.發送Email

Uri uri =Uri.parse("mailto:[email protected]");

Intent it = newIntent(Intent.ACTION_SENDTO, uri);

startActivity(it);

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_EMAIL,"[email protected]");

it.putExtra(Intent.EXTRA_TEXT, "Theemail body text");

it.setType("text/plain");

startActivity(Intent.createChooser(it,"Choose Email Client"));

Intent it=new Intent(Intent.ACTION_SEND);

String[] tos={"[email protected]"};

String[]ccs={"[email protected]"};

it.putExtra(Intent.EXTRA_EMAIL, tos);

it.putExtra(Intent.EXTRA_CC, ccs);

it.putExtra(Intent.EXTRA_TEXT, "Theemail body text");

it.putExtra(Intent.EXTRA_SUBJECT, "Theemail subject text");

it.setType("message/rfc822");

startActivity(Intent.createChooser(it,"Choose Email Client"));

Intent it = newIntent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_SUBJECT, "Theemail subject text");

it.putExtra(Intent.EXTRA_STREAM,"file:///sdcard/mysong.mp3");

sendIntent.setType("audio/mp3");

startActivity(Intent.createChooser(it,"Choose Email Client"));

10.播放多媒體

Intent it = new Intent(Intent.ACTION_VIEW);

Uri uri =Uri.parse("file:///sdcard/song.mp3");

it.setDataAndType(uri,"audio/mp3");

startActivity(it);

Uri uri
=Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,"1");

Intent it = new Intent(Intent.ACTION_VIEW,uri);

startActivity(it);

11.uninstall apk

Uri uri =Uri.fromParts("package", strPackageName, null);

Intent it = newIntent(Intent.ACTION_DELETE, uri);

startActivity(it);

12.install apk

Uri installUri = Uri.fromParts("package","xxx", null);

returnIt = newIntent(Intent.ACTION_PACKAGE_ADDED, installUri);

打開照相機

<1>Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null);

this.sendBroadcast(i);

<2>long dateTaken = System.currentTimeMillis();

String name = createName(dateTaken) + ".jpg";

fileName = folder + name;

ContentValues values = new ContentValues();

values.put(Images.Media.TITLE, fileName);

values.put("_data", fileName);

values.put(Images.Media.PICASA_ID, fileName);

values.put(Images.Media.DISPLAY_NAME, fileName);

values.put(Images.Media.DESCRIPTION, fileName);

values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName);

Uri photoUri = getContentResolver().insert(

MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);

Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);

startActivityForResult(inttPhoto, 10);

14.從gallery選取圖片

Intent i = new Intent();

i.setType("image/*");

i.setAction(Intent.ACTION_GET_CONTENT);

startActivityForResult(i, 11);

打開錄音機

Intent mi = new Intent(Media.RECORD_SOUND_ACTION);

startActivity(mi);

16.顯示應用詳細列表

Uri uri =Uri.parse("market://details?id=app_id");

Intent it = new Intent(Intent.ACTION_VIEW,uri);

startActivity(it);

//where app_id is the application ID, findthe ID

//by clicking on your application on Markethome

//page, and notice the ID from the addressbar

剛才找app id未果,結果發現用package name也可以

Uri uri =Uri.parse("market://details?id=");

這個簡單多了

17尋找應用

Uri uri =Uri.parse("market://search?q=pname:pkg_name");

Intent it = new Intent(Intent.ACTION_VIEW,uri);

startActivity(it);

//where pkg_name is the full package pathfor an application

18打開聯系人列表

<1>

Intent i = new Intent();

i.setAction(Intent.ACTION_GET_CONTENT);

i.setType("vnd.android.cursor.item/phone");

startActivityForResult(i, REQUEST_TEXT);

<2>

Uri uri = Uri.parse("content://contacts/people");

Intent it = new Intent(Intent.ACTION_PICK, uri);

startActivityForResult(it, REQUEST_TEXT);

19 打開另一程序

Intent i = new Intent();

ComponentName cn = newComponentName("com.yellowbook.android2",

"com.yellowbook.android2.AndroidSearch");

i.setComponent(cn);

i.setAction("android.intent.action.MAIN");

startActivityForResult(i, RESULT_OK);

20.調用系統編輯添加聯系人(高版本SDK有效):

Intent it = newIntent(Intent.ACTION_INSERT_OR_EDIT);

it.setType("vnd.android.cursor.item/contact");

//it.setType(Contacts.CONTENT_ITEM_TYPE);

it.putExtra("name","myName");

it.putExtra(android.provider.Contacts.Intents.Insert.COMPANY,
"organization");

it.putExtra(android.provider.Contacts.Intents.Insert.EMAIL,"email");

it.putExtra(android.provider.Contacts.Intents.Insert.PHONE,"homePhone");

it.putExtra(android.provider.Contacts.Intents.Insert.SECONDARY_PHONE,

"mobilePhone");

it.putExtra( android.provider.Contacts.Intents.Insert.TERTIARY_PHONE,

"workPhone");

it.putExtra(android.provider.Contacts.Intents.Insert.JOB_TITLE,"title");

startActivity(it);

21.調用系統編輯添加聯系人(全有效):

Intent intent = newIntent(Intent.ACTION_INSERT_OR_EDIT);

intent.setType(People.CONTENT_ITEM_TYPE);

intent.putExtra(Contacts.Intents.Insert.NAME, "My Name");

intent.putExtra(Contacts.Intents.Insert.PHONE, "+1234567890");

intent.putExtra(Contacts.Intents.Insert.PHONE_TYPE,Contacts.PhonesColumns.TYPE_MOBILE);

intent.putExtra(Contacts.Intents.Insert.EMAIL, "[email protected]");

intent.putExtra(Contacts.Intents.Insert.EMAIL_TYPE,
Contacts.ContactMethodsColumns.TYPE_WORK);

startActivity(intent);

★intent action大全:

android.intent.action.ALL_APPS

android.intent.action.ANSWER

android.intent.action.ATTACH_DATA

android.intent.action.BUG_REPORT

android.intent.action.CALL

android.intent.action.CALL_BUTTON

android.intent.action.CHOOSER

android.intent.action.CREATE_LIVE_FOLDER

android.intent.action.CREATE_SHORTCUT

android.intent.action.DELETE

android.intent.action.DIAL

android.intent.action.EDIT

android.intent.action.GET_CONTENT

android.intent.action.INSERT

android.intent.action.INSERT_OR_EDIT

android.intent.action.MAIN

android.intent.action.MEDIA_SEARCH

android.intent.action.PICK

android.intent.action.PICK_ACTIVITY

android.intent.action.RINGTONE_PICKER

android.intent.action.RUN

android.intent.action.SEARCH

android.intent.action.SEARCH_LONG_PRESS

android.intent.action.SEND

android.intent.action.SENDTO

android.intent.action.SET_WALLPAPER

android.intent.action.SYNC

android.intent.action.SYSTEM_TUTORIAL

android.intent.action.VIEW

android.intent.action.VOICE_COMMAND

android.intent.action.WEB_SEARCH

android.net.wifi.PICK_WIFI_NETWORK

android.settings.AIRPLANE_MODE_SETTINGS

android.settings.APN_SETTINGS

android.settings.APPLICATION_DEVELOPMENT_SETTINGS

android.settings.APPLICATION_SETTINGS

android.settings.BLUETOOTH_SETTINGS

android.settings.DATA_ROAMING_SETTINGS

android.settings.DATE_SETTINGS

android.settings.DISPLAY_SETTINGS

android.settings.INPUT_METHOD_SETTINGS

android.settings.INTERNAL_STORAGE_SETTINGS

android.settings.LOCALE_SETTINGS

android.settings.LOCATION_SOURCE_SETTINGS

android.settings.MANAGE_APPLICATIONS_SETTINGS

android.settings.MEMORY_CARD_SETTINGS

android.settings.NETWORK_OPERATOR_SETTINGS

android.settings.QUICK_LAUNCH_SETTINGS

android.settings.SECURITY_SETTINGS

android.settings.SETTINGS

android.settings.SOUND_SETTINGS

android.settings.SYNC_SETTINGS

android.settings.USER_DICTIONARY_SETTINGS

android.settings.WIFI_IP_SETTINGS

android.settings.WIFI_SETTINGS

android.settings.WIRELESS_SETTINGS

D. Android中AM、PM、mpsys命令使用總結

am指令是 activity manager的縮寫,可以啟動Service、Broadcast,殺進程,監控等功能,這些功能都非常便捷調試程序。

可以通過adb shell 進入Android 的Linux命令界面,輸入am -help查看詳細命令,先介紹幾個簡單用法,

命令格式如下

命令列表:

原理分析:am命令實的實現方式在Am.java,最終幾乎都是調用ActivityManagerService相應的方法來完成的,am monitor除外。比如前面概述中介紹的命令am start -a android.intent.action.VIEW -d https://amberweather.com , 啟動Acitivty最終調用的是ActivityManagerService類的startActivityAsUser()方法來完成的。再比如am kill-all命令,最終的實現工作是由ActivityManagerService的killBackgroundProcesses()方法完成的。

下面說一下[options]和 <INTENT>參數的意義以及如何正確取值。

主要是啟動Activity命令am start [options] <INTENT>使用options參數,接下來列舉Activity命令的[options]參數:

啟動Activity的實現原理: 存在-W參數則調用startActivityAndWait()方法來運行,否則startActivityAsUser()。

命令

例如: 向pid=12345的進程,發出level=RUNNING_LOW的收緊內存命令

level取值范圍為: HIDDEN、RUNNING_MODERATE、BACKGROUND、RUNNING_LOW、MODERATE、RUNNING_CRITICAL、COMPLETE

am的子命令,startservice, stopservice, broadcast, kill, profile start, profile stop, mpheap的可選參數都允許設置--user <USER_ID>。目前市面上的絕大多數手機還是單用戶模式,因此可以忽略該參數,默認為當前用戶。

例如:啟動id=10001的用戶的指定service。

Intent的參數和flags較多,為了方便,這里分為3種類型參數,常用參數,Extra參數,Flags參數

實例

(1). 基本類型

參數es是Extra String首字母簡稱,實例:

(2). 數組類型

參數eia,是Extra int array首字母簡稱,多個value值之間以逗號隔開,實例:

(3). ArrayList類型

參數efal,是Extra float Array List首字母簡稱,多個value值之間以逗號隔開,實例:

pm工具為包管理(package manager)的簡稱,可以使用pm工具來執行應用的安裝和查詢應用寶的信息、系統許可權、控制應用,pm工具是Android開發與測試過程中必不可少的工具,shell命令格式如下:

原理分析:pm命令實的實現方式在Pm.java,最後大多數都是調用PackageManagerService相應的方法來完成的。disbale之後,在桌面和應用程序列表裡邊都看到不該app。

查看所有的package,

[options]參數:

disabled + enabled = 總應用個數; 系統 + 第三方 = 總應用個數。

查看第3方應用:

查看已經被禁用的包名

<FILTER>參數
當FILTER為不為空時,則只會輸出包名帶有FILTER欄位的應用;當FILTER為空時,則默認顯示所有滿足條件的應用。

例如,查看包名帶有weather欄位的包名

[options]參數:

<PATH>參數: 指的是需要安裝的apk所在的路徑

mpsys是Android自帶的強大debug工具,從名字就可以看出,主要是用於mp 當前android system的一些信息,是一項分析手機問題,運行狀態,使用情況等十分有效的手段。

實現原理
mpsys的源碼結構其實很簡單,只有一個mpsys.cpp
/frameworks/native/cmds/mpsys/mpsys.cpp

先通過defaultServiceManager()函數獲得ServiceManager對象,然後根據mpsys傳進來的參數通過函數checkService來找到具體的service, 並執行該service的mp方法,達到mp service的目的。

不同的Android系統版本支持的命令有所不同,可通過下面命令查看當前手機所支持的mp服務,先進入adb shell,再執行如下命令:mpsys -l。 這些服務名可能並看不出其調用的哪個服務,可以通過下面指令:service list。

服務列表有很多,這里簡單介紹幾種

通過下面命令可列印具體某一項服務:mpsys <service>,其中service便是前面表格中的服務名

接下來主要說下mpsys activity 用法

命令

options可選值

mpsys activity等價於依次輸出下面7條指令:

cmd可選值

命令

返回結果

上面的輸出結果可以分為以下四個部分

也可以只輸出某個pid或package的進程信息:

下面以AmberLocker作為實例進行分析

場景1:查詢某個App所有的Service狀態

解讀:Service類名為com.amber.lockscreen.LockerHeartService,包名為mobi.infolife.ezweather.locker.locker_2,baseDir(apk路徑)為/data/app/mobi.infolife.ezweather.locker.locker_2-2/base.apk,dataDir((apk數據路徑)
運行在進程pid=1115,進程名為進程名為mobi.infolife.ezweather.locker.locker_2,,uid=10060,還有創建時間等信息

場景2:查詢某個App所有的廣播狀態

場景3:查詢某個App所有的Activity狀態

場景4:查詢某個App的進程狀態

格式:ProcessRecord{Hashcode pid:進程名/uid},進程pid=941,進程名為mobi.infolife.ezweather.locker.locker_2:live,uid=10060.
該進程中還有Services,Connections, Providers, Receivers,

場景5:查詢棧頂Activity

mpsys 的命令還有很多,這里就不一一列舉了。

E. android如何獲取伺服器端文件列表及相關信息

要弄的話你先要搞清幾個問題,
1、你與服務端的通信協議。如果一般服務端已經開發好了,那麼會有一套通信協議,通常與手機的交互都採用JSON格式發送,減少流量。你可以網路下JSON的相關知識。很簡單的一種格式。如果不是JSON的話一般會是XML,不過很少見。
2、數據量。Android market應用列表見過吧?很多情況下回做成懶載入,而不是刷新所有數據。這樣的話你就要根據數據量考慮你的代碼實現了,合理的使用SoftReference,優化ListView,用sqllite資料庫緩存數據等等,具體機制你需要自己設計一下了,如果你是個PM的話。如果不是PM推薦你找個有經驗的人設計下,否則很容易出現OOM異常

對於數據的處理方面,就像第一條說的,無論是JSON還是XML格式,android都有工具類,用法我就不貼了,自己搜一下,很多的

F. 列出Android設備中所有啟動的服務,及判斷某個服務是否開啟

今天給大家的小例子是列出Android設備中所有啟動的服務,及判斷某個服務是否開啟,具體步驟如下了:
第一步:新建一個Android工程,命名為RunningService。
第二步:修改RunningService.java代碼如下:
package com.tutor.runningservice;
import java.util.List;
import android.app.Activity;
import android.app.ActivityManager;
import android.os.Bundle;
import android.widget.TextView;
public class RunningService extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
TextView mTextView = new TextView(this);
ActivityManager mActivityManager =
(ActivityManager)getSystemService(ACTIVITY_SERVICE);

List<ActivityManager.RunningServiceInfo> mServiceList = mActivityManager.getRunningServices(30);
//我要判斷的服務名字,我在launcher2里加了一個音樂服務
final String musicClassName = "com.android.launcher2.MusicService";

boolean b = MusicServiceIsStart(mServiceList, musicClassName);

mTextView.setText("你要判斷的服務狀態為: " +b+"/n" + getServiceClassName(mServiceList));
setContentView(mTextView);
}
//通過Service的類名來判斷是否啟動某個服務
private boolean MusicServiceIsStart(List<ActivityManager.RunningServiceInfo> mServiceList,String className){

for(int i = 0; i < mServiceList.size(); i ++){
if(className.equals(mServiceList.get(i).service.getClassName())){
return true;
}
}
return false;
}
//獲取所有啟動的服務的類名
private String getServiceClassName(List<ActivityManager.RunningServiceInfo> mServiceList){
String res = "";
for(int i = 0; i < mServiceList.size(); i ++){
res+=mServiceList.get(i).service.getClassName()+ " /n";
}

return res;
}
}
第三步:運行上述工程,查看效果!

G. 怎麼查看Android設備中的啟動服務

有兩種方法,一種是設置里,有個位置和安全的選項,裡面設置允許使用位置服務;第二種(安卓4.0以上)在下拉欄里點擊「位置服務」案件,綠色就表示打開了。以上兩種方法使用時都會在上面有一個位置服務標識中間在閃爍。

H. android中怎樣獲取手機已開啟的應用列表

打開設置—應用程序—管理應用程序—正在運行的服務即可查看,並可以停止運行
用軟體也行,安卓優化大師、360手機助手和騰訊手機管家都行,並可以禁止應用後台自啟動
另外提醒你,短按兩次home鍵是查看最近啟動的應用程序,不能管理,也不是後台運行,只能快速打開

I. Android中服務service

本文原文連接 https://blog.csdn.net/wen20102321/article/details/53155736

Service是Android中的四大組件之一,它的級別和Activity差不多。只不過Service沒有頁面顯示,只能後台運行,可以和其他組件進行交互。
Service的後台運行並不是子線程,是在主線程中進行的,只是它沒有界面顯示。如果Service進行了耗時操作同樣需要開啟子線程,否則會跟Activity一樣出現ANR問題(application not response–程序沒有響應)。
補充說明:
主線程的內容包括UI和後台,只要程序中的UI或者後台其中一個在跑,程序都算是在運行狀態。

1,創建一個自己的TestService繼承Service
2,必須實現重寫其中的onBind方法,可以在里邊做各種操作,也可以接收傳遞過來的Intent的數據。
(在Android Studio中可以直接新建一個Service)

服務的注冊是四大組件中最簡單的一個,一般只要設置name屬性就可以了。

1,startService()啟動
(1)啟動服務startService:onCerate(),onStart()
(2)停止服務stopService:onDestroy()
此方法啟動服務,服務如果未被創建,系統會先調用onCreate()方法,接著調用onStrat()方法。如果調用startService前服務已經被啟動,多次調用啟動方法,不會多次調用onCreate,但會導致多次調用onStrat。
2,bindService()啟動
(1)綁定bindService:onCreate(),onBind()
(2)解除綁定unbindService:onUnbind()
(3)正常停止程序服務的方法是先接觸綁定unbindService,在停止服務stopService
綁定後調用stopService方法,這時候是不能停止服務的,如果這時再調用解綁unbindService,程序會先解綁,後停止服務。
用此方法啟動服務,在服務未被創建時,會先調用onCreate(),接著調用onBind()方法,這時候調用者和服務綁定在一起,調用者退出,系統會先調用服務的onUnbind(),然後onDestroy()。如果調用bindService之前服務已經被綁定,多次調用bindService並不會導致onCreate()和onBind()方法被多次調用。如果調用者想與正在綁定的服務解除綁定,可以調用unbindService()。

(1),onCerate()服務第一次被創建
(2),onStartComand()服務開始工作
(3),onBind()服務已經綁定
(4),onUnBind()服務解綁
(5),onDestroy()服務已經停止

普通的Service進行耗時操作要創建一個線程去完成,因為service是在主線程運行的,並且這個子線程完成工作要手動停止 。IntentService是繼承了Service並處理起步請求的一個類,在IntentService內有一個工作線程,來處理耗時操作,啟動IntentService的方式和啟動傳統的Service是一樣,當任務執行完成後,IntentService會自動停止,而不需要我們去控制。
可以啟動多次IntentService,每一個耗時操作會以工作隊列的方式在IntentService的onHandleIntent回調方法中執行,並且每次只會執行一個工作線程,執行完第一個再執行第二個,以此類推,而且,所有請求都在一個單線程中,不會阻塞主線程,同一時間只處理一個請求。
IntentService優點
1,省去了在Service中開線程的麻煩
2,當操作完成時,不用手動停止Service。IntentService是Service,但是比Service更智能。

J. Android中Service服務有哪些

Service分為本地服務(LoaclService)和遠程服務(RemoteService)。
本地服務:用於應用程序內部,這也與客戶端(可以理解也activity)進行通信就很方便。
遠程服務:用於android系統內部的應用程序之間。

閱讀全文

與android服務列表相關的資料

熱點內容
voc文件夾 瀏覽:862
租廣東聯通伺服器注意什麼雲空間 瀏覽:932
javascript高級程序設計pdf 瀏覽:289
pwm單片機原理 瀏覽:346
ai演算法在線修復圖片 瀏覽:979
scratch編程中如何做射擊游戲 瀏覽:476
at89c51編程器 瀏覽:341
項目經理叫醒程序員 瀏覽:342
autocad旋轉命令 瀏覽:660
手機版wpsoffice怎麼打包文件夾 瀏覽:579
在成都學車用什麼app 瀏覽:818
grep命令管道 瀏覽:426
java修改重啟 瀏覽:567
單片機供電方案 瀏覽:770
airpodspro一代怎麼連接安卓 瀏覽:218
豌豆莢app上有什麼游戲 瀏覽:285
公路商店app標簽選什麼 瀏覽:339
linuxoracle命令行登錄 瀏覽:227
android深度休眠 瀏覽:173
php微信開發例子 瀏覽:846