相关疑难解决方法(0)

你如何使用bundle传递android活动之间的图像(位图)?

假设我有一个从库中选择图像的活动,并将其作为BitMap检索,就像示例:here

现在,我想传递此BitMap以在ImageView中用于另一个活动.我知道bundle可以在活动之间传递,但是我如何将这个BitMap存储到bundle中?

还是我应该采取另一种方法?

android bundle image

50
推荐指数
4
解决办法
11万
查看次数

方向改变时保存对象

如何在方向更改时保存Object,因为不推荐使用onRetainNonConfigurationInstancegetLastNonConfigurationInstance.它不能与我一起使用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-fragments

36
推荐指数
3
解决办法
2万
查看次数

在Android应用程序上旋转屏幕时如何防止数据丢失?

我在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)

java arrays android

2
推荐指数
1
解决办法
1564
查看次数

标签 统计

android ×3

android-fragments ×1

arrays ×1

bundle ×1

image ×1

java ×1