【问题标题】:Focusing on text input field after opening activity from push notification从推送通知打开活动后专注于文本输入字段
【发布时间】:2015-12-07 15:00:02
【问题描述】:

我有 NoteListActivity,我有搜索栏,通过方法调用:

private void searchClicked(MenuItem item) {
    searchText.setText(AppConstant.NULL_STRING);
    searchBgr.setVisibility(View.VISIBLE);
    searchText.requestFocus();
    showKeyBoard();
}

我需要从通知栏中打开该特定方法。 我设法打开了那个特定的活动,但我不知道如何在我想要关注的活动中调用方法。

这是通知栏活动的意图:

Intent searchIntent = new Intent(context, NoteListActivity.class);
    searchIntent.putExtra(AppConstant.FIXED_NOTIFICATION_SEARCH_KEY, true);
    int searchPendingIntentId = AppConstant.FIXED_NOTIFICATION_SEARCH_ID;
    PendingIntent searchPendingIntent = PendingIntent.getActivity(context, searchPendingIntentId, searchIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

【问题讨论】:

    标签: java android android-intent android-notifications


    【解决方案1】:
    onCreate(){
    
        if(getIntent().getBooleanExtra (AppConstant.FIXED_NOTIFICATION_SEARCH_KEY,false) ){
    
            searchText.setText(AppConstant.NULL_STRING);
            searchBgr.setVisibility(View.VISIBLE);
            searchText.requestFocus();
            showKeyBoard();
        }
    }
    

    【讨论】:

    • 我收到错误“无法解析方法 getBoolean,而 getBooleanExtra 没有从通知栏打开活动。
    • getBooleanExtra 没有从通知栏打开活动是什么意思?
    猜你喜欢
    • 1970-01-01
    • 2015-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多