【发布时间】:2015-02-23 04:17:31
【问题描述】:
场景
我的应用程序是从 Activity C (A->B->C) 打开的第 3 方应用程序。之后,第 3 方应用程序完成它返回到我在 Activity C 上的应用程序。一切正常,直到 Activity C 中只有一个 EditText 正在使用软键盘输入并且我想关闭它。
软键盘冻结而不关闭,我的应用也没有冻结。
- 我的测试设备基于 Android KitKat。
- 我更改为默认和自定义的其他键盘.. 没有希望
- 我按下主页按钮并再次返回我的应用程序软键盘行为正常。
这是我的示例 XML(重现此错误)
活动 A
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Go to Activity B"
android:id="@+id/btnNext"/>
</LinearLayout>
活动 B
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Go To Activity C"
android:id="@+id/btnNext"/>
</LinearLayout>
活动 C
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_medium"
android:background="#DEE1E3"
android:id="@+id/llReceiverContainer">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_default"
android:hint="Receiver Name"
android:id="@+id/edtReceiver"/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="@dimen/button_height_big"
android:layout_marginBottom="@dimen/padding_default"
android:layout_marginLeft="@dimen/padding_default"
android:layout_marginRight="@dimen/padding_default"
android:text="Ex. Call 3rd Party App"
android:textColor="#fff"
android:textStyle="bold"
android:textSize="@dimen/font_large"
android:id="@+id/btnTestMpos"/>
</LinearLayout>
</ScrollView>
这是我的示例类(A->B->C 只需调用 startActivity)
类活动C
public class ActivityC extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_c);
Button btnTestMpos = (Button) findViewById(R.id.btnTestMpos);
EditText edtUser = (EditText) findViewById(R.id.edtReceiver);
btnTestMpos.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
payWithMPOS();
}
});
}
private void payWithMPOS() {
//call thire pparty application
}
// return from 3rd party application
protected void onNewIntent(Intent intent) {
setIntent(intent);
getResultFromMPOS();
}
public void getResultFromMPOS() {
// extract result from 3rd party applicaiton
}
}
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ui.keyboard"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="14"/>
<uses-permission android:name="android.permission.GET_TASKS" >
</uses-permission>
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity android:name=".ActivityA"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".ActivityB"
android:label="@string/app_name">
</activity>
<activity android:name=".ActivityC"
android:launchMode="singleTask"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.example.mpos.integration" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
【问题讨论】:
标签: android