我从CallBack方法调用Handler,方法是,
public void callback(String fileName) {
Log.d("Callback", "In call back method");
System.out.println("--File = " + fileName);
File d = new File(fileName);
if (d.isDirectory()) {
System.out.println("Is a directory ");
} else {
System.out.println("is a file");
Bundle data = new Bundle();
data.putString("path", fileName);
Message msg = new Message();
msg.setData(data);
mfileObserver.sendMessage(msg);
// mfileObserver.sendEmptyMessage(10);
System.out.println("--msg is = " + msg);
System.out.println("--File = " + fileName);
//showDialog(fileName);
}
我想通过处理程序调用活动,这里我将文件路径传递给activity.My处理程序代码是,
mfileObserver = new Handler() {
public void handleMessage(Message msg) {
if (msg.what == 10) {
final Bundle msgData = msg.getData();
Log.d("FileObserverTest",
"handler " + msgData.getString("path"));
System.out.println("in handler----- = ");
System.out.println("path is----- = " + msgData.getString("path"));
showDialog(msgData.getString("path"));
// some(msgData.getString("path"));
}
}
};
请帮助我。
答案 0 :(得分:0)
Intent dialogIntent = new Intent(this, CachingActivity.class);
Bundle bundle = new Bundle();
bundle.putInt("something", someInt);
dialogIntent .putExtras(bundle);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(dialogIntent);