Thinking in Google Doc-不同的Apps之间的交互
1.隐式意图
怎么传值我就不细说了,说些一般人不知道的吧。
1)Verify There is an App to Receive the Intent(判断是否有App响应了意图)
you should always include averification step before invoking an intent.
Caution: If you invoke an intent and there is no appavailable on the device that can handle the intent, your app will crash.(没有应用处理意图,应用就会挂掉。)
因为你不能保证每个手机上都有你需要的应用!
PackageManager packageManager = getPackageManager()
;
List activities = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
boolean isIntentSafe = activities.size() > 0;
If isIntentSafe
is true
, then at least one app will respond tothe intent. If it is
false
, then there aren't any apps to handle the intent.
2)
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。