Android: android Intent and IntentFilter
1. intentfilter description:
If you want to open another application of an activity, or call our own activity in webView or bybird app,
You can use intentfilter to filter the activities we need;
* Uri parameter description Java Code:
final Uri uri = Uri.parse(intbird://com.intbird.soft/testing/tested?name='Test'); TextView textView = (TextView)findViewById(R.id.textView); textView.setText(uri.getScheme() + //intbird + uri.getPort() + //-1 + uri.getAuthority() + //com.intbird.soft + uri.getHost() + //com.intbird.soft + uri.getPath() + // /testing/tested + uri.getPathSegments() + // [tesing,tested] + uri.getQuery()+); // name='Text'
Public void onClick (View v) {Intent intent = new Intent (); intent. setAction (android. intent. action. VIEW); intent. setData (uri); PackageManager packageManager = getPackageManager (); List
Activities = packageManager. queryIntentActivities (intent, 0); boolean isIntentSafe = activities. size ()> 0; if (isIntentSafe) {startActivity (intent);} else {Toast. makeText (MainActivity. this matches None, Toast. LENGTH_SHORT ). show ();}}
XML Code:
NOTE: The category label must exist.
2. Better understanding of webpage calls
Uri:
Final Uri urihttp = Uri. parse ("https://www.baidu.com/s? Wd = intbird ");
// Schma: http
// Host: www.baidu.com
// Path:/s
// Query: wd = intbird
XML
Match scheme and multiple hosts. Intent Chooser is displayed.
3. Similarly, if we have multiple activities;
If both are the same:
So:
But: add path [android: path = "/testing"] to one, startActivity directly