简体   繁体   中英

How to solve this issue i got only in Moto g?

在此处输入图片说明 i am try to choose image form gallery and crop the image.i tested more than 5 devices i got only problem with Moto g.how to solve this problem?i am using TabGroupActivity

my code

parent activity

public class TabGroup1Activity extends TabGroupActivity{

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startChildActivity("OptionsActivity", new Intent(this,ProfileActivity.class));
}


protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) throws ClassCastException {
   if (requestCode == 1) {
       Family activity = (Family)getLocalActivityManager().getCurrentActivity();
       activity.onActivityResult(requestCode, resultCode, intent);
    }
    else if (requestCode == 2) {
        Home activity = (Home)getLocalActivityManager().getCurrentActivity();
        activity.onActivityResult(requestCode, resultCode, intent);
        }

child activity:

Intent intent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);`enter code here`

    getParent().startActivityForResult(
            Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);`




public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {`switch (requestCode) {
    case SELECT_PICTURE:
        try {
            mImageCaptureUri = data.getData();
            doCrop();
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
}}

`

Note that your activity may be recreated on posting result from gallery or camera.Please save your current state of the activity in onSavedInstatnceStae() and restore the same if your activity is recreated. Refer Here for more info

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("ImageUri", imageUri);
 }

protected void restoreSavedInstanceState(Bundle savedInstanceState) {
imageUri = savedInstanceState.getString("ImageUri");
}

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null)
  {
    restoreSavedInstanceState(savedInstanceState);
   }
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM