点击短信中的url打开某个应用

实现功能:
短信内容中含有url(例如, http://youngo.com/app/ ),点击后打开apk

遗留问题:
点击url后,会出现选择框,让用户选择是用浏览器打开仍是用该apk打开————没有找到方法如何不出现该选择框??

参考:

一、应用中AndroidManifest.xml配置——主要
   
   
   
   
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.msgintenapptest" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <uses-permission android:name="android.permission.SEND_SMS"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".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> <data android:scheme="http" android:host="youngo.com" android:pathPrefix="/app/"> </data> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> </intent-filter> </activity> </application></manifest>

二、测试发送短信
   
   
   
   
private Button.OnClickListener button_clickListener = new Button.OnClickListener(){ @Override public void onClick(View v) { try { URL url = new URL("http://youngo.com/app/"); intentToSms("18511111111",url.toString()); } catch (MalformedURLException e) { e.printStackTrace(); } } }; private void intentToSms(String tel, String msg){ Uri uri = Uri.parse("smsto:"+tel); Intent intent = new Intent(Intent.ACTION_SENDTO,uri); intent.putExtra("sms_body", msg); startActivity(intent); }





附件列表

相关文章
相关标签/搜索