Androidã§ãã©ã¦ã¶ããèªåã®ã¢ããªãèµ·åããã
1.AndroidManifest.xmlã«å®ç¾©ã追å ãã¾ãã
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="co.jp.millmo.android.sample" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <!--ãããã©ã«ãã§è¨è¿°ããå®ç¾©ããã®é¨åãæ¶ãã¨ãã¡ãã¥ã¼ã¢ã¤ã³ã³ãæ¶ãã¾ãããã®æ¹ãé½åãããæãããã¾ããã --> <activity android:label="@string/app_name" android:name=".CallCS"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!--ãããã©ã«ãã§è¨è¿°ããå®ç¾©ãçµãã --> <!--ããã©ã¦ã¶ããã®èµ·åããããã®å®ç¾© --> <activity android:label="@string/app_name" android:name=".CallCS"> <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="testcall"/> </intent-filter> </activity> <!--ããã©ã¦ã¶ããã®èµ·åããããã®å®ç¾©çµãã --> </application> <uses-sdk android:minSdkVersion="3" /> </manifest>
2.ãã©ã¦ã¶ããã®ã¢ããªã®å¼ã³åºãã
htmlã«ä»¥ä¸ãè¨è¿°
<html> <body> <head><title>cs</title></head> <center><a href="testcall://test/">testcall</a></center> </body> </html>
3.ããã°ã©ã ã«ä»¥ä¸ã®ãããªè¨è¿°ã追å ãã¦ããã©ã¡ã¼ã¿ãåå¾ãã¾ãã
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //ã¬ã¤ã¢ã¦ããè¨å® setContentView(R.layout.main); // å¤ã®åå¾ Intent intent = getIntent(); String action = intent.getAction(); Log.d("Dbg", "action = [" + action + "]"); if (Intent.ACTION_VIEW.equals(action)) { //ãã©ã¦ã¶ããèµ·åãããå ´å Uri uri = intent.getData(); //uriã«ã¯ãã©ã¦ã¶ã§è¨å®ãããtestcall://test/ãã¨schemeåãå«ãã¦åå¾ããã¾ãã Log.d("Dbg", "uri = [" + uri.toString() + "]"); } else if(Intent.ACTION_MAIN.equals(action)){ //ã¢ã¤ã³ã³ã®ã¯ãªãã¯ã§èµ·åããå ´å } }