1. A service runs in the main thread of its hosting process—the service does not create
its own thread and does not run
in a separate process (unless you specify otherwise)
service雖然沒有UI,也不可以做耗時操作,否則依舊有ActivityManager報ANR,即使將service設定到另外一個process中也不行,雖然當前process的UI不會阻塞了,可是後台列印log發現,另一個process裡的service在大約30s後ANR了。。而且沒有ANR的提示框彈出。。。
2.startActivity
<activity
android:name="com.example.call.MyActivity"
android:label="@string/app_name2" >
<intent-filter >
<action android:name="ritter.com"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
當使用隱式調用activity時,一定要在intent-filter裡指定category DEFAULT,因為預設的Intent會建立category DEFAULT。
Android treats all implicit intents passed to startActivity() as if they contained at least one category: "android.intent.category.DEFAULT"
(the CATEGORY_DEFAULT constant). Therefore, activities that are willing to receive implicit intents must include "android.intent.category.DEFAULT" in their intent filters