zoukankan      html  css  js  c++  java
  • 点击短信中的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);
    }





    附件列表

    • 相关阅读:
      11.28 正则表达式
      12.28jQuery 的取值赋值
      11.27 上传下载 图片预览
      11.28 验证控件
      12.23,repeater 分页显示
      12.23,搜索标记
      1.基础CRUD
      C#杀进程与之之子进程
      使用procedump捕获未处理异常的dump
      [.net core] 12.环境变量
    • 原文地址:https://www.cnblogs.com/Amandaliu/p/5098470.html
    Copyright © 2011-2022 走看看