Java 类org.apache.cordova.api.CordovaPlugin 实例源码

项目:cordova-android-chromeview    文件:CameraLauncher.java   
/**
     * Take a picture with the camera.
     * When an image is captured or the camera view is cancelled, the result is returned
     * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult.
     *
     * The image can either be returned as a base64 string or a URI that points to the file.
     * To display base64 string in an img tag, set the source to:
     *      img.src="data:image/jpeg;base64,"+result;
     * or to display URI in an img tag
     *      img.src=result;
     *
     * @param quality           Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
     * @param returnType        Set the type of image to return.
     */
    public void takePicture(int returnType, int encodingType) {
        // Save the number of images currently on disk for later
        this.numPics = queryImgDB(whichContentStore()).getCount();

        // Display camera
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");

        // Specify file so that large image is captured and returned
        File photo = createCaptureFile(encodingType);
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
        this.imageUri = Uri.fromFile(photo);

        if (this.cordova != null) {
            this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1);
        }
//        else
//            LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
    }
项目:cordova-android-chromeview    文件:CameraLauncher.java   
/**
 * Get image from photo library.
 *
 * @param quality           Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
 * @param srcType           The album to get image from.
 * @param returnType        Set the type of image to return.
 */
// TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do!
public void getImage(int srcType, int returnType) {
    Intent intent = new Intent();
    String title = GET_PICTURE;
    if (this.mediaType == PICTURE) {
        intent.setType("image/*");
    }
    else if (this.mediaType == VIDEO) {
        intent.setType("video/*");
        title = GET_VIDEO;
    }
    else if (this.mediaType == ALLMEDIA) {
        // I wanted to make the type 'image/*, video/*' but this does not work on all versions
        // of android so I had to go with the wildcard search.
        intent.setType("*/*");
        title = GET_All;
    }

    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    if (this.cordova != null) {
        this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent,
                new String(title)), (srcType + 1) * 16 + returnType + 1);
    }
}
项目:cordova-android-chromium    文件:CameraLauncher.java   
/**
     * Take a picture with the camera.
     * When an image is captured or the camera view is cancelled, the result is returned
     * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult.
     *
     * The image can either be returned as a base64 string or a URI that points to the file.
     * To display base64 string in an img tag, set the source to:
     *      img.src="data:image/jpeg;base64,"+result;
     * or to display URI in an img tag
     *      img.src=result;
     *
     * @param quality           Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
     * @param returnType        Set the type of image to return.
     */
    public void takePicture(int returnType, int encodingType) {
        // Save the number of images currently on disk for later
        this.numPics = queryImgDB(whichContentStore()).getCount();

        // Display camera
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");

        // Specify file so that large image is captured and returned
        File photo = createCaptureFile(encodingType);
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
        this.imageUri = Uri.fromFile(photo);

        if (this.cordova != null) {
            this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1);
        }
//        else
//            LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
    }
项目:cordova-android-chromium    文件:CameraLauncher.java   
/**
 * Get image from photo library.
 *
 * @param quality           Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
 * @param srcType           The album to get image from.
 * @param returnType        Set the type of image to return.
 */
// TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do!
public void getImage(int srcType, int returnType) {
    Intent intent = new Intent();
    String title = GET_PICTURE;
    if (this.mediaType == PICTURE) {
        intent.setType("image/*");
    }
    else if (this.mediaType == VIDEO) {
        intent.setType("video/*");
        title = GET_VIDEO;
    }
    else if (this.mediaType == ALLMEDIA) {
        // I wanted to make the type 'image/*, video/*' but this does not work on all versions
        // of android so I had to go with the wildcard search.
        intent.setType("*/*");
        title = GET_All;
    }

    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    if (this.cordova != null) {
        this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent,
                new String(title)), (srcType + 1) * 16 + returnType + 1);
    }
}
项目:12306-android-Decompile    文件:DroidGap.java   
protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
{
  LOG.d(TAG, "Incoming Result");
  super.onActivityResult(paramInt1, paramInt2, paramIntent);
  Log.d(TAG, "Request code = " + paramInt1);
  ValueCallback localValueCallback = this.appView.getWebChromeClient().getValueCallback();
  if (paramInt1 == 5173)
  {
    Log.d(TAG, "did we get here?");
    if (localValueCallback == null)
      return;
    if ((paramIntent != null) && (paramInt2 == -1))
      break label187;
  }
  CordovaPlugin localCordovaPlugin1;
  label187: for (Object localObject = null; ; localObject = paramIntent.getData())
  {
    Log.d(TAG, "result = " + localObject);
    localValueCallback.onReceiveValue(localObject);
    localCordovaPlugin1 = this.activityResultCallback;
    if (localCordovaPlugin1 != null)
      break label196;
    if (this.initCallbackClass == null)
      break;
    this.activityResultCallback = this.appView.pluginManager.getPlugin(this.initCallbackClass);
    CordovaPlugin localCordovaPlugin2 = this.activityResultCallback;
    LOG.d(TAG, "We have a callback to send this result to");
    localCordovaPlugin2.onActivityResult(paramInt1, paramInt2, paramIntent);
    return;
  }
  label196: LOG.d(TAG, "We have a callback to send this result to");
  localCordovaPlugin1.onActivityResult(paramInt1, paramInt2, paramIntent);
}
项目:12306-android-Decompile    文件:DroidGap.java   
public void startActivityForResult(CordovaPlugin paramCordovaPlugin, Intent paramIntent, int paramInt)
{
  this.activityResultCallback = paramCordovaPlugin;
  this.activityResultKeepRunning = this.keepRunning;
  if (paramCordovaPlugin != null)
    this.keepRunning = false;
  super.startActivityForResult(paramIntent, paramInt);
}
项目:cordova-android-chromeview    文件:CordovaActivity.java   
/**
 * Launch an activity for which you would like a result when it finished. When this activity exits,
 * your onActivityResult() method will be called.
 *
 * @param command           The command object
 * @param intent            The intent to start
 * @param requestCode       The request code that is passed to callback to identify the activity
 */
public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
    this.activityResultCallback = command;
    this.activityResultKeepRunning = this.keepRunning;

    // If multitasking turned on, then disable it for activities that return results
    if (command != null) {
        this.keepRunning = false;
    }

    // Start activity
    super.startActivityForResult(intent, requestCode);
}
项目:cordova-android-chromeview    文件:CordovaActivity.java   
@Override
    /**
     * Called when an activity you launched exits, giving you the requestCode you started it with,
     * the resultCode it returned, and any additional data from it.
     *
     * @param requestCode       The request code originally supplied to startActivityForResult(),
     *                          allowing you to identify who this result came from.
     * @param resultCode        The integer result code returned by the child activity through its setResult().
     * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
     */
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        LOG.d(TAG, "Incoming Result");
        super.onActivityResult(requestCode, resultCode, intent);
        Log.d(TAG, "Request code = " + requestCode);
        ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        if (requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
            Log.d(TAG, "did we get here?");
            if (null == mUploadMessage)
                return;
            Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
            Log.d(TAG, "result = " + result);
//            Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
//            Log.d(TAG, "result = " + filepath);
            mUploadMessage.onReceiveValue(result);
            mUploadMessage = null;
        }
        CordovaPlugin callback = this.activityResultCallback;
        if(callback == null && initCallbackClass != null) {
            // The application was restarted, but had defined an initial callback
            // before being shut down.
            this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
            callback = this.activityResultCallback;
        }
        if(callback != null) {
            LOG.d(TAG, "We have a callback to send this result to");
            callback.onActivityResult(requestCode, resultCode, intent);
        }
    }
项目:cordova-android-chromeview    文件:Capture.java   
/**
 * Sets up an intent to capture images.  Result handled by onActivityResult()
 */
private void captureImage() {
    // Save the number of images currently on disk for later
    this.numPics = queryImgDB(whichContentStore()).getCount();

    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

    // Specify file so that large image is captured and returned
    File photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), "Capture.jpg");
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));

    this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_IMAGE);
}
项目:cordova-android-chromeview    文件:Capture.java   
/**
 * Sets up an intent to capture video.  Result handled by onActivityResult()
 */
private void captureVideo(int duration) {
    Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);

    if(Build.VERSION.SDK_INT > 7){
        intent.putExtra("android.intent.extra.durationLimit", duration);
    }
    this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO);
}
项目:12306-android-Decompile    文件:DroidGap.java   
protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
{
  LOG.d(TAG, "Incoming Result");
  super.onActivityResult(paramInt1, paramInt2, paramIntent);
  Log.d(TAG, "Request code = " + paramInt1);
  ValueCallback localValueCallback = this.appView.getWebChromeClient().getValueCallback();
  if (paramInt1 == 5173)
  {
    Log.d(TAG, "did we get here?");
    if (localValueCallback == null)
      return;
    if ((paramIntent != null) && (paramInt2 == -1))
      break label187;
  }
  CordovaPlugin localCordovaPlugin1;
  label187: for (Object localObject = null; ; localObject = paramIntent.getData())
  {
    Log.d(TAG, "result = " + localObject);
    localValueCallback.onReceiveValue(localObject);
    localCordovaPlugin1 = this.activityResultCallback;
    if (localCordovaPlugin1 != null)
      break label196;
    if (this.initCallbackClass == null)
      break;
    this.activityResultCallback = this.appView.pluginManager.getPlugin(this.initCallbackClass);
    CordovaPlugin localCordovaPlugin2 = this.activityResultCallback;
    LOG.d(TAG, "We have a callback to send this result to");
    localCordovaPlugin2.onActivityResult(paramInt1, paramInt2, paramIntent);
    return;
  }
  label196: LOG.d(TAG, "We have a callback to send this result to");
  localCordovaPlugin1.onActivityResult(paramInt1, paramInt2, paramIntent);
}
项目:12306-android-Decompile    文件:DroidGap.java   
public void startActivityForResult(CordovaPlugin paramCordovaPlugin, Intent paramIntent, int paramInt)
{
  this.activityResultCallback = paramCordovaPlugin;
  this.activityResultKeepRunning = this.keepRunning;
  if (paramCordovaPlugin != null)
    this.keepRunning = false;
  super.startActivityForResult(paramIntent, paramInt);
}
项目:cordova-android-chromium    文件:CordovaActivity.java   
/**
 * Launch an activity for which you would like a result when it finished. When this activity exits,
 * your onActivityResult() method will be called.
 *
 * @param command           The command object
 * @param intent            The intent to start
 * @param requestCode       The request code that is passed to callback to identify the activity
 */
public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
    this.activityResultCallback = command;
    this.activityResultKeepRunning = this.keepRunning;

    // If multitasking turned on, then disable it for activities that return results
    if (command != null) {
        this.keepRunning = false;
    }

    // Start activity
    super.startActivityForResult(intent, requestCode);
}
项目:cordova-android-chromium    文件:CordovaActivity.java   
@Override
    /**
     * Called when an activity you launched exits, giving you the requestCode you started it with,
     * the resultCode it returned, and any additional data from it.
     *
     * @param requestCode       The request code originally supplied to startActivityForResult(),
     *                          allowing you to identify who this result came from.
     * @param resultCode        The integer result code returned by the child activity through its setResult().
     * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
     */
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        LOG.d(TAG, "Incoming Result");
        super.onActivityResult(requestCode, resultCode, intent);
        Log.d(TAG, "Request code = " + requestCode);
        ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        if (requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
            Log.d(TAG, "did we get here?");
            if (null == mUploadMessage)
                return;
            Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
            Log.d(TAG, "result = " + result);
//            Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
//            Log.d(TAG, "result = " + filepath);
            mUploadMessage.onReceiveValue(result);
            mUploadMessage = null;
        }
        CordovaPlugin callback = this.activityResultCallback;
        if(callback == null && initCallbackClass != null) {
            // The application was restarted, but had defined an initial callback
            // before being shut down.
            this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
            callback = this.activityResultCallback;
        }
        if(callback != null) {
            LOG.d(TAG, "We have a callback to send this result to");
            callback.onActivityResult(requestCode, resultCode, intent);
        }
    }
项目:cordova-android-chromium    文件:Capture.java   
/**
 * Sets up an intent to capture images.  Result handled by onActivityResult()
 */
private void captureImage() {
    // Save the number of images currently on disk for later
    this.numPics = queryImgDB(whichContentStore()).getCount();

    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

    // Specify file so that large image is captured and returned
    File photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), "Capture.jpg");
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));

    this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_IMAGE);
}
项目:cordova-android-chromium    文件:Capture.java   
/**
 * Sets up an intent to capture video.  Result handled by onActivityResult()
 */
private void captureVideo(double duration) {
    Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);

    if(Build.VERSION.SDK_INT > 8){
        intent.putExtra("android.intent.extra.durationLimit", duration);
    }
    this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO);
}
项目:foreground-gallery-plugin    文件:ForegroundGalleryLauncher.java   
/**
 * Get image from photo library.
 */
public void getImage()
{
    Intent intent = new Intent(this.cordova.getActivity().getApplicationContext() , GalleryActivity.class);
    this.cordova.startActivityForResult((CordovaPlugin) this, intent, 11);
}
项目:12306-android-Decompile    文件:DroidGap.java   
public void setActivityResultCallback(CordovaPlugin paramCordovaPlugin)
{
  this.activityResultCallback = paramCordovaPlugin;
}
项目:cordova-android-chromeview    文件:CordovaDriverAction.java   
public void startActivityForResult(CordovaPlugin command, Intent intent,
        int requestCode) {
    // TODO Auto-generated method stub

}
项目:cordova-android-chromeview    文件:CordovaWebViewTestActivity.java   
public void startActivityForResult(CordovaPlugin command, Intent intent,
        int requestCode) {
    // TODO Auto-generated method stub

}
项目:cordova-android-chromeview    文件:CordovaActivity.java   
public void setActivityResultCallback(CordovaPlugin plugin) {
    this.activityResultCallback = plugin;
}
项目:cordova-android-chromeview    文件:Capture.java   
/**
 * Sets up an intent to capture audio.  Result handled by onActivityResult()
 */
private void captureAudio() {
    Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION);

    this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_AUDIO);
}
项目:12306-android-Decompile    文件:DroidGap.java   
public void setActivityResultCallback(CordovaPlugin paramCordovaPlugin)
{
  this.activityResultCallback = paramCordovaPlugin;
}
项目:cordova-android-chromium    文件:CordovaActivity.java   
public void setActivityResultCallback(CordovaPlugin plugin) {
    this.activityResultCallback = plugin;
}
项目:cordova-android-chromium    文件:Capture.java   
/**
 * Sets up an intent to capture audio.  Result handled by onActivityResult()
 */
private void captureAudio() {
    Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION);

    this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_AUDIO);
}
项目:foreground-camera-plugin    文件:ForegroundCameraLauncher.java   
/**
 * Take a picture with the camera. When an image is captured or the camera
 * view is cancelled, the result is returned in
 * CordovaActivity.onActivityResult, which forwards the result to
 * this.onActivityResult.
 * 
 * The image can either be returned as a base64 string or a URI that points
 * to the file. To display base64 string in an img tag, set the source to:
 * img.src="data:image/jpeg;base64,"+result; or to display URI in an img tag
 * img.src=result;
 * 
 */    
public void takePicture() {
    // Save the number of images currently on disk for later
    this.numPics = queryImgDB().getCount();

    Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), CameraActivity.class);
    this.photo = createCaptureFile();
    this.imageUri = Uri.fromFile(photo);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri);

    this.cordova.startActivityForResult((CordovaPlugin) this, intent, 1);
}
项目:foreground-camera-plugin    文件:ForegroundCameraLauncher.java   
/**
 * Take a picture with the camera. When an image is captured or the camera
 * view is cancelled, the result is returned in
 * CordovaActivity.onActivityResult, which forwards the result to
 * this.onActivityResult.
 * 
 * The image can either be returned as a base64 string or a URI that points
 * to the file. To display base64 string in an img tag, set the source to:
 * img.src="data:image/jpeg;base64,"+result; or to display URI in an img tag
 * img.src=result;
 * 
 */    
public void takePicture() {
    // Save the number of images currently on disk for later
    this.numPics = queryImgDB().getCount();

    Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), CameraActivity.class);
    this.photo = createCaptureFile();
    this.imageUri = Uri.fromFile(photo);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri);

    this.cordova.startActivityForResult((CordovaPlugin) this, intent, 1);
}
项目:cordova-android-chromeview    文件:CordovaDriverAction.java   
public void setActivityResultCallback(CordovaPlugin plugin) {
    // TODO Auto-generated method stub

}
项目:cordova-android-chromeview    文件:CordovaWebViewTestActivity.java   
public void setActivityResultCallback(CordovaPlugin plugin) {
    // TODO Auto-generated method stub

}