Advertisement
Guest User

webintent.js

a guest
Jul 9th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * cordova Web Intent plugin
  3.  * Copyright (c) Boris Smus 2010
  4.  *
  5.  */
  6.  (function(cordova){
  7.     var WebIntent = function() {
  8.  
  9.     };
  10.  
  11.     WebIntent.prototype.ACTION_SEND = "android.intent.action.SEND";
  12.     WebIntent.prototype.ACTION_VIEW= "android.intent.action.VIEW";
  13.     WebIntent.prototype.EXTRA_TEXT = "android.intent.extra.TEXT";
  14.     WebIntent.prototype.EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
  15.     WebIntent.prototype.EXTRA_STREAM = "android.intent.extra.STREAM";
  16.     WebIntent.prototype.EXTRA_EMAIL = "android.intent.extra.EMAIL";
  17.  
  18.     WebIntent.prototype.startActivity = function(params, success, fail) {
  19.         console.log(params, success, fail);
  20.        
  21.         return cordova.exec(function(args) {          
  22.             success(args);
  23.         }, function(args) {
  24.             fail(args);
  25.         }, 'WebIntent', 'startActivity', [params]);
  26.     };
  27.  
  28.     WebIntent.prototype.hasExtra = function(params, success, fail) {
  29.         return cordova.exec(function(args) {
  30.             success(args);
  31.         }, function(args) {
  32.             fail(args);
  33.         }, 'WebIntent', 'hasExtra', [params]);
  34.     };
  35.  
  36.     WebIntent.prototype.getUri = function(success, fail) {
  37.         return cordova.exec(function(args) {
  38.             success(args);
  39.         }, function(args) {
  40.             fail(args);
  41.         }, 'WebIntent', 'getUri', []);
  42.     };
  43.  
  44.     WebIntent.prototype.getExtra = function(params, success, fail) {
  45.         return cordova.exec(function(args) {
  46.             success(args);
  47.         }, function(args) {
  48.             fail(args);
  49.         }, 'WebIntent', 'getExtra', [params]);
  50.     };
  51.  
  52.  
  53.     WebIntent.prototype.onNewIntent = function(callback) {
  54.         return cordova.exec(function(args) {
  55.             callback(args);
  56.         }, function(args) {
  57.         }, 'WebIntent', 'onNewIntent', []);
  58.     };
  59.  
  60.     WebIntent.prototype.sendBroadcast = function(params, success, fail) {
  61.         return cordova.exec(function(args) {
  62.             success(args);
  63.         }, function(args) {
  64.             fail(args);
  65.         }, 'WebIntent', 'sendBroadcast', [params]);
  66.     };
  67.  
  68.     cordova.addConstructor(function() {
  69.         window.webintent = new WebIntent();
  70.        
  71.         // backwards compatibility
  72.         window.plugins = window.plugins || {};
  73.         window.plugins.webintent = window.webintent;
  74.     });
  75. })(window.PhoneGap || window.Cordova || window.cordova);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement