Question

so having a bit of an issue (which is related to - Camera Crashing due to Background Process Limit

I have a fair few users who's phones have "Do not Keep Activities" set or "Background Processes" set to 2 or something like that, which when opening other intents will cause the app to seemingly "crash"

So I am having an issue with something like this

intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);

the EXTRA_OUTPUT for Gallery is ignored - it works for the Camera (after onResume I have the URI of the temp image which I process afterwards)

But what do I do for the native gallery?

My current process for when taking a photo from the camera is

  1. Create the intent, use EXTRA_OUTPUT
  2. If it doesn't crash, then onActivityResult is called
  3. If it does crash - after rebooting from the bundle state instance, restores everything then processes the image as normal

I want to replicate the same thing for Gallery; but EXTRA_OUTPUT is ignored on the gallery. I have been looking around for a while. I would rather not have to make my own gallery if I don't have to (I suppose worst case I will have to do that; but I'm hoping there's another way)

Was it helpful?

Solution

Well seems like I always end up answering my own, this time the key laid in using onActivityResult on the main thread (the answer seems soo obvious now)

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{

    Log.e("Instance", "onActivityResult called.");
    super.onActivityResult(requestCode, resultCode, intent);

    //we use this to go through the channels IF the app has been restarted.
    if(this.activityResultCallback == null)
    {
        ...
    }
}

however I am having an issue with this

if(intent != null)
{
   Log.e("Instance", intent.getAction()); //this crashes?
}

I am certain getAction is being set via Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

But the result is coming back with an image (I checked the debugger and it gives me the full content path) - just no action associated?

edit: This was just due to my lack of Android knowledge, I had not realized onActivityResult was called and chained down in PhoneGap but now it all makes sense, however still having issues with getAction() being null. I'm happy finally got everything working, but I can't figure out the getAction being null. Since I get back content:// i just make it assume its passing back a photo for me

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top