EDIT: Đã giải quyết. Câu trả lời được đăng riêng bên dướiBàn phím Android vẫn hiển thị sau khi khởi chạy Mục đích email
Tôi đang khởi chạy Intent.ACTION_SEND "trình chọn" để người dùng có thể chọn cách gửi thư từ ứng dụng của tôi. Nó hoạt động OK, nhưng nếu tôi nhấn 'Discard' trong chương trình Email được khởi chạy, nó sẽ trở lại ứng dụng của tôi với bàn phím ảo vẫn hiển thị. Tôi đã cố gắng đóng nó với nhiều câu thần chú của imm.hideSoftInputFromWindow (...) nhưng vô ích. Bất kỳ ý tưởng làm thế nào để sửa lỗi này?
Đây là cách tôi khởi chạy 'trình chọn' và cố gắng đóng bàn phím trong onActivityResult(). Lưu ý rằng tabHost là một thành viên tĩnh trong ứng dụng chính của tôi (MainApp) chứa đối tượng tabHost được sử dụng để tạo tabSpecs.
public class L_Secondary extends ListActivity implements myConst
{
@Override
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
setContentView(R.layout.l_people_secondary);
// instantiate the custom array adapter class and pass it some info to build a ListView with.
ListView lv = getListView();
lv.setOnItemClickListener (oicl);
A_secondary da = new A_secondary (this, android.R.layout.simple_list_item_single_choice, mPiecesArray, mPartsArray);
setListAdapter (da);
}
...
// after launching the email client, the keyboard stays visible
// over the Listview. Currently the keyboard gets forced to close
// in getView() of the ArrayAdapter class da, in onCreate() above
public void launchEmail()
{
try
{
// use the builtin chooser for users mail app
Intent sendIntent = new Intent(Intent.ACTION_SEND, Uri.fromParts ("mailto", "[email protected]", null));
sendIntent.setType("text/plain");
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "msg_subject");
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, "msg_body");
startActivityForResult (Intent.createChooser(sendIntent, "Send via which Application?"), 0);
}
catch (Exception e)
{
Toast.makeText (this, "No activity was found to handle this action",Toast.LENGTH_SHORT).show();
}
}
...
}
Tại sao tính năng này hoạt động?Tôi cần hiểu để cố gắng sử dụng nó trong tình huống của mình. – Poutrathor