假设我有一个从库中选择图像的活动,并将其作为BitMap检索,就像示例:here
现在,我想传递此BitMap以在ImageView中用于另一个活动.我知道bundle可以在活动之间传递,但是我如何将这个BitMap存储到bundle中?
还是我应该采取另一种方法?
如何在方向更改时保存Object,因为不推荐使用onRetainNonConfigurationInstance和getLastNonConfigurationInstance.它不能与我一起使用compatibility package android-support-v4.jar FragmentActivity,它在哪里显示Cannot override the final method from FragmentActivity
开发者网站说
使用新的Fragment API setRetainInstance(boolean)代替;
但我不知道如何使用setRetainInstance保存自定义对象
我的场景:
在我的活动中,我有一个带有进度对话框的AsyncTask.在这里,我需要处理方向变化.
为此,我从Mark Murphy得到了一个非常好的答案,CommonsWare
背景 - 任务 - 进展 - 对话 - 导向 - 改变 - 在那里 - 任何 - 100 - 工作,
与示例项目
由于我使用兼容性包android-support-v4.jar FragmentActivity,我无法覆盖onRetainNonConfigurationInstance
无法覆盖FragmentActivity的最终方法
有没有其他方法可以保存我的自定义对象?
编辑:
我不能使我的AsyncTask任务Parcelable(如果我没错),因为它使用接口,上下文等我的AsyncTask
public class CommonAsyncTask extends AsyncTask<Object, Object, Object> {
Context context;
AsyncTaskServices callerObject;
ProgressDialog progressDialog;
String dialogMessag ;
................
Run Code Online (Sandbox Code Playgroud)
我在寻找,是否有onRetainNonConfigurationInstance方法的 …
我在Android应用程序上旋转屏幕时发现了一个问题.
我的android应用程序是通过音频插孔接收信号然后存储在缓冲区中来实时显示ECG(心电图)信号.虽然它有效,但当我旋转屏幕时,信号会从屏幕上丢失,但应用程序没有关闭.我怎么解决这个问题?
public class MainActivity extends Activity {
ChartView lineChart;
private final Handler mHandler = new Handler();
private Runnable mTimer1;
private final Handler mHandler2 = new Handler();
private Runnable mTimer2;
private int CHART_LEN = 20000;
private int SLIDE_LEN = 1;
Queue<String> dataQueue = new LinkedList<String>();
Queue<String> chartDataQueue = new LinkedList<String>();
float points[] = new float[CHART_LEN];
// Properties (MIC)
public AudioRecord audioRecord;
public int mSamplesRead;
public int recordingState;
public int buffersizebytes;
public int channelConfiguration = AudioFormat.CHANNEL_IN_MONO;
public int audioEncoding = AudioFormat.ENCODING_PCM_16BIT; …Run Code Online (Sandbox Code Playgroud)