Starting activity from phonegap plugin-webIntent

落爺英雄遲暮 提交于 2019-12-23 01:27:09

问题


I have configured webintent plugin in my android app . I want to start an activity from a button click on my UI page . The activity takes no params . I have gone through this link https://github.com/phonegap/phonegap-plugins/tree/master/Android/WebIntent/ but i m not getting how to call a such a simple activity . Not able to get the what url field is used for .... . One more , are thing any configuration required in manifest file such as intent filters for calling activity .


回答1:


Not sure if that could help :

https://github.com/phonegap/phonegap-plugins/issues/1009

https://github.com/Richardsonke/phonegap-plugins/commit/d0343f49022d9ece97f70af42400636d8d0a64d8

EDIT 1: Ok I got it working now, in your AndroidManifest.xml add these Lines ( Inside the Activity you want the Button to go to )

<intent-filter>
     <action android:name="com.example.yourapplication.UNIQUESTRING" />
     <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

be sure to change "com.example.yourapplication" to your package and UNIQUESTRING to be something Unique

in Javascript make the button fires this JS :

window.plugins.webintent.startActivity(
  {
    action: 'com.example.yourapplication.UNIQUESTRING',
  }, 
  function() {}, 
  function() {alert('Failed to open URL via Android Intent')}
);


来源:https://stackoverflow.com/questions/17336248/starting-activity-from-phonegap-plugin-webintent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!