Re: [問題] android Service ?
後來我發現是
Intent intent=new Intent();
intent.setClass(MainActivity.this,fileAdd.class);
Bundle bundle=new Bundle();
bundle.putString("str",saveStr);
intent.putExtras(bundle);
startActivity(intent);
這裡造成我不能按menu,後來將另一個java檔的class內容,移到同一個java下,
就解決問題了,不過我還是想問下次如果再遇到同樣問題該如何解決,我有看到上一篇
有人回答用handler但是我本身這段程式碼就是寫在handler裡面,我將程式碼在列在下方
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE:
byte[] readBuf = (byte[]) msg.obj;
int [] dataBuf = new int [msg.arg1];
for(int i=0;i<msg.arg1;i++)
dataBuf[i] = readBuf[i] & 0xff;
int [] handleBuf = new int [5];
handleBuf[0]=dataBuf[1]*256+dataBuf[2];
handleBuf[1]=dataBuf[3]*256+dataBuf[4];
handleBuf[2]=dataBuf[5];
handleBuf[3]=dataBuf[6];
handleBuf[4]=dataBuf[7]*256+dataBuf[8];
String SaveStr="....";
tvOutPutOne.setText(Integer.toString(handleBuf[2]));
tvOutPutTwo.setText(Integer.toString(handleBuf[3]));
Intent intent=new Intent();
intent.setClass(MainActivity.this,fileAdd.class);
Bundle bundle=new Bundle();
bundle.putString("str",saveStr);
intent.putExtras(bundle);
startActivity(intent);
break;
};
這個handler 是由另一個java回傳的訊息,我有想用再另一個handler來處理,
但我不知道該如何得到這個handler 內的變數(byte [] readBuf)?
問題
1. 原本就已經使用handler,但同樣會造成menu無法點選,該如何解決?
2. 如何取的上述handler內的變數?
謝謝大家
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.241.209.170
→
06/03 01:46, , 1F
06/03 01:46, 1F
→
06/03 01:46, , 2F
06/03 01:46, 2F
→
06/03 01:46, , 3F
06/03 01:46, 3F
→
06/03 09:04, , 4F
06/03 09:04, 4F
→
06/03 09:05, , 5F
06/03 09:05, 5F
→
06/03 12:01, , 6F
06/03 12:01, 6F
→
06/03 12:17, , 7F
06/03 12:17, 7F
→
06/03 12:32, , 8F
06/03 12:32, 8F
→
06/03 12:33, , 9F
06/03 12:33, 9F
→
06/03 12:33, , 10F
06/03 12:33, 10F
→
06/03 12:34, , 11F
06/03 12:34, 11F
→
06/03 12:49, , 12F
06/03 12:49, 12F
→
06/03 15:06, , 13F
06/03 15:06, 13F
→
06/03 15:09, , 14F
06/03 15:09, 14F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):