从Android浏览器(并不是Appliaction里面的webkit)打开应用程序/应用商店

本文介绍如何通过在AndroidManifest.xml中定义特定scheme实现从浏览器直接启动Android应用的方法,并提供了一个具体的例子。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚才为了测试在android浏览器中一个应用程序,走了一点弯路,在这里记录下来


androidManifest.xml

[html]  view plain copy
  1. <activity android:name=".UploadActivity" android:screenOrientation="portrait">  
  2.     <intent-filter>  
  3.         <strong><span style="color:#ff0000;"><data android:scheme="mtcmtc"/></span></strong>  
  4.     <action android:name="android.intent.action.VIEW" />  
  5.     <category android:name="android.intent.category.DEFAULT" />  
  6.     <category android:name="android.intent.category.BROWSABLE" />  
  7.     </intent-filter>  
  8. </activity>  

浏览器中的超链接 <a href="mtcmtc://aaaaa/aaa">点击打开程序</a>


从浏览器中直接打开Android Market Place,这个market schema 是Google已经配置好了的,可以直接使用。

<a href="market://search?q=pname:com.nytimes.android">点击打开商店</a>


点击打开程序

点击打开Market

### 解决方案 当遇到 `application.properties` 文件在打包后的 Spring Boot JAR 中丢失的问题时,通常是因为文件未被正确包含到最终的构建产物中。以下是详细的解决方案: #### 1. 确认资源目录配置 确保项目的 `application.properties` 文件位于标准的 Maven 或 Gradle 资源路径下,即 `src/main/resources/` 目录[^1]。 如果项目结构不遵循此约定,则需要手动调整构建工具的资源配置。例如,在 Maven 的 `pom.xml` 中可以这样指定额外的资源路径: ```xml <build> <resources> <resource> <directory>custom/path/to/resources</directory> <includes> <include>**/*.properties</include> </includes> </resource> </resources> </build> ``` #### 2. 验证构建过程中的资源复制行为 运行以下命令来验证 `application.properties` 是否已成功复制到目标 JAR 文件中: ```bash jar tf target/kkfileview.jar | grep application.properties ``` 如果没有找到该文件,则可能是构建过程中遗漏了它。此时应检查构建脚本是否正确处理了资源文件。 #### 3. 使用 Spring Boot 提供的功能加载外部配置 即使 `application.properties` 缺失,也可以通过设置环境变量或命令行参数的方式提供必要的配置项。例如: ```java public static void main(String[] args) { SpringApplication app = new SpringApplication(MainApplication.class); app.setDefaultProperties(Collections.singletonMap("spring.config.location", "classpath:/config/application.properties")); app.run(args); } ``` 上述代码片段强制指定了一个备用位置用于读取配置文件[^3]。 另外还可以利用 Java 命令启动应用时附加 `-Dspring.config.location` 参数指向实际存在的 `.properties` 文件副本。 #### 4. 检查是否存在多模块冲突 对于复杂的多模块项目来说,可能存在不同子模块间覆盖或者忽略某些共享资源的情况。务必确认父 POM 和各子模块间的继承关系定义清晰无误,且所有依赖都声明得当。 --- ### 示例代码修正版 下面给出一个完整的示例程序入口类实现方式作为参考: ```java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class KkFileViewApplication { public static void main(String[] args) { System.setProperty("spring.config.name", "application"); System.setProperty("spring.config.additional-location", "classpath:/,file:./config/"); SpringApplication.run(KkFileViewApplication.class, args); } } ``` 以上方法能够有效应对大多数因缺少默认配置而导致的服务异常场景。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值