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

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

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

参考:

1、应用中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>

2、测试发送短信

   
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);
}





附件列表

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值