9

I followed this to capture Images form camera in webview

Here at this part its fine in android some versions and in some devices its working fine

But at android 5.0.1 when I capture image from webview its capturing and reloading the page again in that I am again redirecting to Login page

So i am Unable to upload but where as in Huvai p9 its wokring fine with android 6+ its working fine It stays fine and uploads the Image can any one suggest me what to do

Update 1

Now I tried many other ways like this

But its not working in some devices Please Help but in some devices its working fine...

Don't Be negative
  • 1,215
  • 3
  • 19
  • 46

2 Answers2

1

According to me the activity that hosts the web view is destroyed as soon as you open the camera to take the picture. The camera is loaded in a separate activity, and this can cause the web view activity to be stopped and destroyed on devices with low memory.

Basically you have to manage this case, for example, in your onCreate where you will get a not null savedInstanceState bundle in case your activity has been destroyed and recreated. Check also the result that you get back in onActivityResult before loading content of the web view.

Mimmo Grottoli
  • 5,758
  • 2
  • 17
  • 27
  • Sir In that what should I need to Replace in `not null savedInstanceState bundle` can you suggest me sir... But how ever its working fine in some devices but why its not working in some devices – Don't Be negative Oct 26 '16 at 07:18
  • Sir I have Given this `@Override protected void onSaveInstanceState(Bundle outState ) { super.onSaveInstanceState(outState); webView.saveState(outState); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); webView.restoreState(savedInstanceState); }` Please check my code whether Its given properly or not please help me sir... – Don't Be negative Oct 26 '16 at 07:23
  • Sir Can you Update your Answer In [my code ](https://github.com/mgks/Os-FileUp/blob/master/app/src/main/java/com/inf/os/fileup/MainActivity.java) so that I can tick bounty to you – Don't Be negative Oct 26 '16 at 07:37
  • Sir If i do that I am getting msg error Cache missing... Yes In previous after Giving This only Its worked on some devices But its working fine in some devices after giving this and in some devices i am getting error cache missing – Don't Be negative Oct 26 '16 at 08:03
1

I faced with a same problem. My mistake was that i was doing that.

protected void onStart() {
    super.onStart();
    browser.loadUrl(siteUrl);
}

But onStart sometime fires after you select a file.

Maybe it will help.

Ec7ipse
  • 17
  • 2
  • 6