Android: android Intent and IntentFilter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.