Activity中关键代码:
//得到应用管理器
PackageManager pm = getPackageManager();
Intent intent = new Intent();
intent.setAction("org.lang.intent");
Uri data = Uri.parse("http://www.baidu.com:8080/2302");
intent.setDataAndType(data, "p_w_picpath/png");
//遍历所以的app查询符合过滤条件的activity
List<ResolveInfo> app = pm.queryIntentActivities(intent, 0);
if(app.size() > 0)
{
startActivity(intent );
}
else
{
Toast.makeText(this, "没有匹配的Activity", Toast.LENGTH_SHORT).show();
}
androidManifast.xml文件中:
<activity
android:name="com.example.emp.MainActivity3"
android:label="@string/title_activity_main_activity3" >
<intent-filter>
<action android:name="org.lang.intent" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.baidu.com"
android:path="/2302"
android:port="8080"
android:scheme="http" />
<data android:mimeType="p_w_picpath/jpg" />
</intent-filter>
</activity>
具体代码附近