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