點擊短信中的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);
}





附件列表

     


    免責聲明!

    本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



     
    粵ICP備18138465號   © 2018-2025 CODEPRJ.COM