h***@163.com
h***@163.com
  • 发布:2019-07-10 14:05
  • 更新:2020-06-05 19:41
  • 阅读:1840

离线打包,被第三方调用,plus.runtime.arguments获取到不到参数

分类:HTML5+

app离线打包的
app如果没有存在于后台,是直接被三方app调用打开,通过plus.runtime.arguments获取到不到参数
app如果存在于后台,是被第三app从后台唤醒,通过plus.runtime.arguments则能获取到参数
离线打包,想直接打开就获取到参数,是不是还要添加什么配置?

在AndroidManifest.xml里添加了配置
android:exported="true"

<activity  
            android:name="io.dcloud.PandoraEntry"  
            android:configChanges="orientation|keyboardHidden|keyboard|navigation"  
            android:label="@string/app_name"  
            android:launchMode="singleTask"  
            android:hardwareAccelerated="true"  
            android:theme="@style/TranslucentTheme"  
            android:screenOrientation="user"  
            android:windowSoftInputMode="adjustResize"  
            android:exported="true">  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>  
        </activity>

被调用页面代码:

<!DOCTYPE html>  
<html>  
<head>  
    <meta charset="utf-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />  
    <title></title>  
    <script type="text/javascript">  
    	  
   		document.addEventListener('plusready',function(){    
		    checkArguments();   
		    // 处理从后台恢复    
		},false);    
		   
		function checkArguments(){    
		    alert("直接启动的: "+plus.runtime.launcher);    
		    var args= plus.runtime.arguments;    
		    alert("参数:"+plus.runtime.arguments);  
		    if(args){    
		        // 处理args参数,如直达到某新页面等    
		    }    
		}    
                // 判断启动方式   
		document.addEventListener('newintent',function(){    
		    alert("从后台恢复的: newintent");    
		    checkArguments();    
		},false);   
    </script>  
</head>  
<body>  
	被调用页面  
</body>  
</html>

调用app的代码:

<!DOCTYPE html>  
<html>  
	<head>  
		<meta charset="UTF-8">  
		<title></title>  
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />  
		<script type="text/javascript" src="js/jquery.min.js" ></script>  
	</head>  
	<body>  
		<input type="button" value="跳转" onclick="tiaozhuan()" /><br/>  
	</body>  
	<script>  
		function tiaozhuan(){  
			plus.runtime.launchApplication(   
				{pname:"com.xxx.xxx",  
				newTask:true,  
				extra:{"abc":"123"}  
				},   
				function ( e ) {  
					alert( "Open system default browser failed: " + e.message );  
				}  
			);  
		}  
		  
	</script>  
</html>
2019-07-10 14:05 负责人:无 分享
已邀请:
h***@163.com

h***@163.com (作者)

来人看看呐。。。

DCloud_Android_zl

DCloud_Android_zl

需要在Androidmanifest.xml中的io.dcloud.PandoraEntry节点下添加scheme配置,可参考如下示例:

<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="hbuilder" />  
            </intent-filter>

将hbuilder替换成需要出发的scheme即可。

  • h***@163.com (作者)

    这样改了以后,app安装以后,图标都找不见了,,啥情况呀,,也没看见报错呀,能否提供下完整写法,就用我例子上的代码就行,安卓0基础,帮帮忙


    2019-07-10 18:29

  • h***@163.com (作者)

    就只需要Androidmanifest.xml中的代码就行


    2019-07-10 18:30

  • h***@163.com (作者)

    我加上了以后,还是一样,直接启动获取不到参数,要第二次启动才能获取。但是在线打包是好的,就离线打包不行,,啥情况呐,,快疯了


    2019-07-11 09:50

h***@163.com

h***@163.com (作者)

<activity  
            android:name="io.dcloud.PandoraEntry"  
            android:configChanges="orientation|keyboardHidden|keyboard|navigation"  
            android:label="@string/app_name"  
            android:launchMode="singleTask"  
            android:hardwareAccelerated="true"  
            android:theme="@style/TranslucentTheme"  
            android:screenOrientation="user"  
            android:windowSoftInputMode="adjustResize"  
            android:exported="true">  
           <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="jianyi" />  
            </intent-filter>  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>  
        </activity>

这个地方的配置应该怎么去写呢??改来改去都不对啊

h***@163.com

h***@163.com (作者)

测试包在附件里面

2***@qq.com

2***@qq.com - uniapp、安卓

遇到同样问题, 第一次启动 plus.runtime.arguments获取到不到参数 关闭页面重进以后才能获取到参数

皮卡丘q

皮卡丘q - 需要技术支援的程序媛

uni-app也有这样的问题,请问有人知道解决方案吗?

该问题目前已经被锁定, 无法添加新回复