0

Im working with Sencha Touch however this is more a general question.

I have implemented an image file upload example with a simple html input type file.

Running the example from an Android browser, like Chrome, when I press the select file button, the camera appears as an option to get the file. However, if I package the applcation via Phonegap, when I press the button, only the File Manager and similar applications can be selected.

Also I have tried with input type file, accept image/* and capture camera with no success.

Is it possible that the Android WebView that renders the page is not fully functional as the Chrome view is?

Do I have another standard option to choose the camera insted of using Phonegap?

Thanks!

gonzalomelov
  • 971
  • 1
  • 13
  • 30
  • don't use input type file, it's broken on android 4.4 http://stackoverflow.com/questions/19882331/html-file-input-in-android-webview-android-4-4-kitkat – jcesarmobile Mar 04 '14 at 13:07
  • Hey @gonzalomelov, just wonder if you've found anything useful about your situation? I am in the exact same setup as yours (ST2 + phonegap) and have the exact same question. Most answers I found here are irrelevant as people are either suggesting things like "using 2 buttons" or "" and such. I just want to know that if it's possible that I am missing a simple setup/config or I will have to redesign my capture workflow. – JChow May 26 '14 at 05:13
  • @JChow, I have searched a lot without success. The final solution we developed included two buttons and the Phonegap Camera plugin. It would be great if Android allow the input tag for packaged apps like iOS does. Cheers! – gonzalomelov May 26 '14 at 11:47
  • Thanks for responding. I indeed have given up digging around shortly after I post my comment. I used one button and then pop up and ask user for take a photo or choose a photo. As much as I realize, a lot of native apps do that indeed so I think that's fine for me as long as I can maintain a one-button design in my main layout. – JChow May 27 '14 at 01:56

1 Answers1

0

I'm surprised PhoneGap does not expose a function that will handle this--they certainly ask for every permission under the sun!

if you are creating the webpage, you certainly can define a js interface that will in turn do a startActivityForResult, like so:

today.setToNow();
    PackageManager pm = getPackageManager();
//  if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
//  {
        Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.EXTRA_OUTPUT, FileContentProvider.CONTENT_URI);       
        if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA))
            i.putExtra("camerasensortype", 1); // call the rear camera          
        else if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT))
            i.putExtra("camerasensortype", 2); // call the front camera         
        else Toast.makeText(getBaseContext(), "Camera is not available", Toast.LENGTH_LONG).show();
        i.putExtra("autofocus", true);
        i.putExtra("fullScreen", false);
        i.putExtra("showActionIcons", false);
        startActivityForResult(i, CAMERA_REQUEST);  
//  }       
    else askForGPS(this);

and then

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK && requestCode == CAMERA_REQUEST)
    {...} 

don't even need to implement an interface =]

then you've got your picture; set up a ContentProvider and point your uploader at that. =]