1.AndroidManifest.xml
2.activity_main.xml
3.MainActivity.java
package tw.android; import java.util.List; import android.app.Activity; import android.net.Uri; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends Activity { private TextView textView1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView1 = (TextView) findViewById(R.id.textView1); Uri data = getIntent().getData(); if (data != null) { String scheme = data.getScheme(); // "uccu" // String host = data.getHost(); List<String> params = data.getPathSegments(); String first = params.get(0); // word1 String second = params.get(1); // word2 textView1.setText(scheme + ":///" + first + "/" + second); }else{ textView1.setText("請從網頁來"); } } }4.web.html
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <a href="uccu:///word1/word2/">啟動吧!!APP!!!</a> </body> </html>
參考來源:
http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser
沒有留言 :
張貼留言