Stuck with Getting Camera Pic When Using the Tab Activity

Issue with onActivityResult in tab activity

Please check this links. May be it is useful for you.

Android onActivityResult NEVER called

How to return a result (startActivityForResult) from a TabHost Activity?

Android Use startActivityForResult from a nested activity in a tab.

camera application gets stuck after taking pic and do not return to my application

Working with files has been chnaged in API 24.
Here is the solution for you:

https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en

When i try to get the Uri from a picture taken with the camera i get null

Android might have killed off (and restarted) your activity before you get into onActivityResult, for instance because you rotated your device while taking the picture. Try to store and restore outputFileUri with the rest of the Activity state...

protected void onSaveInstanceState(Bundle outState)
{
outState.putParcelable("outputFileUri", outputFileUri);
}

...

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

if (savedInstanceState != null)
{
outputFileUri= savedInstanceState.getParcelable("outputFileUri");
}
}

Intent chooser stays open when using a Thread to get an image resource

Feeling pretty stupid, but I found the solution.

The issue was in step two: "The Intent chooser automatically opens..."

In order to do this, I was checking to see if a bitmap was available, and if it wasn't then it should display the placeholder image and then open the Intent chooser. I had this logic inside the onStart method which normally gets run after onActivityResult. However, because this was all happening asynchronously, I could not rely on this order.

What I had to do was put in a boolean flag which could tell me if we were waiting for a bitmap, and then not open the chooser if we were.

Take photo from camera in fragment

I tried your code its working fine dude. I changed

PhotosListFragment.this.startActivityForResult(intent, 100);

to

getActivity().startActivityForResult(intent, 100);

which after taking the picture, returning back to same activity.

I think both of your fragments are on same activity.

if that is the situation, I suggest you to create a new activity and put the new fragment in there.



Related Topics



Leave a reply



Submit