Android opens its own app via the Internet (scheme)
Last Update:2015-08-13
Source: Internet
Author: User
<span id="Label3"></p><p><p>By using the Phone's browser (internal. Third parties Can) access the Web page, click on a link, start implementing their own applications, and transfer Data.</p></p><p><p>The first mainifest to the file start activity add Filter.</p></p><p><p></p></p><pre code_snippet_id="423279" snippet_file_name="blog_20140709_1_9944378" name="code" class="java"><pre code_snippet_id="423279" snippet_file_name="blog_20140709_1_9944378" name="code" class="java"><activity android:name= "com.example.helloworld.MainActivity" android:label= "@string/app_name" > <intent-filter> <action android:name= "android.intent.action.MAIN"/> <category Android:name= "android.intent.category.LAUNCHER"/> </intent-filter> <intent-filter>< Action android:name= "android.intent.action.VIEW"/> <category android:name= " Android.intent.category.DEFAULT "/> <category android:name=" Android.intent.category.BROWSABLE "/> <data android:scheme= "znn"/> </intent-filter> </activity></pre></pre><br>Receive data at Mainactivity:<p><p></p></p><p><p></p></p><pre code_snippet_id="423279" snippet_file_name="blog_20140709_2_3073515" name="code" class="java"><pre code_snippet_id="423279" snippet_file_name="blog_20140709_2_3073515" name="code" class="java">public class Mainactivity extends Activity implements view.onclicklistener{@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); setcontentview (r.layout.activity_main); Intent Intent = Getintent (); String scheme = Intent.getscheme (); Uri uri = Intent.getdata (); System.out.println ("scheme:" +scheme); If (uri! = null) {String host = Uri.gethost (); String datastring = intent.getdatastring (); String id = uri.getqueryparameter ("d"); String Path = Uri.getpath (); String path1 = Uri.getencodedpath (); String queryString = Uri.getquery (); System.out.println ("host:" +host); System.out.println ("datastring:" +datastring); System.out.println ("id:" +id); System.out.println ("path:" +path); System.out.println ("path1:" +path1); System.out.println ("queryString:" +querystring);}}</pre></pre><br><br><p><p></p></p><p><p>Write one of the simplest pages:</p></p><p><p></p></p><pre code_snippet_id="423279" snippet_file_name="blog_20140709_3_9169036" name="code" class="html"><pre code_snippet_id="423279" snippet_file_name="blog_20140709_3_9169036" name="code" class="html"><a href= "znn://aa.bb:80/test?p=12&d=1" >test</a></pre></pre><br><br><p><p></p></p><br>Test Address: www.erdian.net/m.html<br><br><p><p></p></p><p><p>Test Results:</p></p><p><p>Scheme:znn<br>Host:aa.bb<br>datastring:znn://aa.bb:80/test?</p></p><p><p>P=12&id=1<br>Id:1<br>Path:/test<br>Path1:/test<br></p></p><p><p>Querystring:p=12&d=1<br></p></p><p><p><br></p></p><p><p></p></p><p><p>p=238 ">http://www.erdian.net/?</p></p><p><p>p=238<br></p></p> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article blog original articles, blogs, without consent, may not be reproduced.</p></p><p><p></p></p> <p><p>Android opens its own app via the Internet (scheme)</p></p></span>