Delete screenshot after intent has finished
This commit is contained in:
parent
b30c1e4aa3
commit
bd6a98725f
@ -863,7 +863,12 @@ public class IITC_Mobile extends Activity
|
|||||||
// quality is ignored by PNG
|
// quality is ignored by PNG
|
||||||
throw new IOException("Could not compress bitmap!");
|
throw new IOException("Could not compress bitmap!");
|
||||||
}
|
}
|
||||||
startActivity(ShareActivity.forFile(this, file, "image/png"));
|
startActivityForResult(ShareActivity.forFile(this, file, "image/png"), new ResponseHandler() {
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(final int resultCode, final Intent data) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
Log.e("Could not generate screenshot", e);
|
Log.e("Could not generate screenshot", e);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class ShareActivity extends FragmentActivity implements ActionBar.TabListener {
|
public class ShareActivity extends FragmentActivity implements ActionBar.TabListener {
|
||||||
private static final String EXTRA_TYPE = "share-type";
|
private static final String EXTRA_TYPE = "share-type";
|
||||||
|
private static final int REQUEST_START_INTENT = 1;
|
||||||
private static final String TYPE_FILE = "file";
|
private static final String TYPE_FILE = "file";
|
||||||
private static final String TYPE_PERMALINK = "permalink";
|
private static final String TYPE_PERMALINK = "permalink";
|
||||||
private static final String TYPE_PORTAL_LINK = "portal_link";
|
private static final String TYPE_PORTAL_LINK = "portal_link";
|
||||||
@ -85,6 +86,18 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
|||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||||
|
if (REQUEST_START_INTENT == requestCode) {
|
||||||
|
setResult(resultCode, data);
|
||||||
|
// parent activity can now clean up
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -132,6 +145,7 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
|||||||
addTab(mGenerator.getShareIntents(mTitle, uri, mime), R.string.tab_share, R.drawable.ic_action_share);
|
addTab(mGenerator.getShareIntents(mTitle, uri, mime), R.string.tab_share, R.drawable.ic_action_share);
|
||||||
} else {
|
} else {
|
||||||
Log.w("Unknown sharing type: " + type);
|
Log.w("Unknown sharing type: " + type);
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,8 +200,9 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
|
|||||||
public void launch(final Intent intent) {
|
public void launch(final Intent intent) {
|
||||||
mComparator.trackIntentSelection(intent);
|
mComparator.trackIntentSelection(intent);
|
||||||
mGenerator.cleanup(intent);
|
mGenerator.cleanup(intent);
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
// we should wait for the new intent to be finished so the calling activity (IITC_Mobile) can clean up
|
||||||
|
startActivityForResult(intent, REQUEST_START_INTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user