如果应用程序正在启动两次从超链接打开 [英] Application is launching twice if opening from a hyperlink

查看:129
本文介绍了如果应用程序正在启动两次从超链接打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发可以从多个地方,如例如启动一个应用程序超链接在日历中。
我对着在下面的场景中的问题:
如果应用程序已经启动并在后台运行,用户单击本地日历事件/超链接,启动机应用。我的应用程序作为一个新的实例启动两次。在运行的应用程序列表,我可以看到我的应用程序的两个实例。
我已经试过这两个机器人:launchMode =singleInstance和singleInstance属性我的主要activity.but仍然没有工作。任何人都可以建议我解决?

我的清单看起来象下面这样:

 <应用
机器人:allowBackup =真
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动机器人:名字=com.org.ManishApp
机器人:configChanges =键盘| keyboardHidden |方向|屏幕尺寸
机器人:launchMode =singleInstance>
<意向滤光器>进入`code here`
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>


解决方案

让你在添加了这个意图过滤你的清单

 <意向滤光器>
                <作用机器人:名字=android.intent.action.VIEW/>                <类机器人:名字=android.intent.category.DEFAULT/>
                <类机器人:名字=android.intent.category.BROWSABLE/>                <数据机器人:计划=HTTP/>
                <数据
                    机器人:主机=yify-torrents.com
                    机器人:路径preFIX =//>
            &所述; /意图滤光器>

路径preFIX是域名,example.com的子目录

I am developing one application which can be launched from multiple places like e.g. hyperlink in Calendar. I am facing the problem in the below scenario: If application is already launched and running in the background and User clicks the event/hyperlink in Native calendar to start the appliction. My application is launching twice as a new instance. In the running app list I can see the two instances of my application. I have tried both android:launchMode="singleInstance" and "singleInstance" attribute for my Main activity.but still not working. Can anyone suggest me the solution?

My Manifest looks like below:

<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.org.ManishApp" 
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" 
android:launchMode="singleInstance">
<intent-filter>`enter code here`
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

解决方案

Have you added this intent filter in your manifest

<intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data
                    android:host="yify-torrents.com"
                    android:pathPrefix="/" />
            </intent-filter>

pathprefix is the sub-directory after domain "example.com"

这篇关于如果应用程序正在启动两次从超链接打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆