我实现了一个对话框,要求用户输入 PIN 以确保安全,该对话框在应用程序运行时显示,但键盘显示qwerty 键盘,但在 xml 中我设置了inputType="numberpassword"并且在 quetry 中按下任何键都不会在 EditText 中进行任何输入。但是在最小化应用程序并再次打开后,它将显示一个数字键盘,当应用程序开始时我需要显示它。 可能是哪个问题??下面我粘贴了代码和截图。
开始
protected void onStart() {
super.onStart();
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
lock_app = SP.getBoolean("lock_app", false);
LockImmediately(this);
}
public void LockImmediately(Context context) {
if (lock_app) {
final View myview = LayoutInflater.from(context).inflate(R.layout.activity_pwd, null);
enterPWD = (EditText) myview.findViewById(R.id.pwdValue);
Log.d("myerror", pwd);
AlertDialog alertDialog = new AlertDialog.Builder(context).setIcon(R.drawable.ic_lock_black_24dp).setCancelable(false)
.setView(myview).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String user_text = enterPWD.getText().toString();
if ((pwd.equals(user_text))) {
dialog.dismiss();
} else {
dialog.dismiss();
MainActivity.this.finish();
}
}
}).create();
alertDialog.show();
}
}
@Override
protected void onPause() {
super.onPause();
if (bottom_addView!=null){
bottom_addView.pause();
}
}
活动密码.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter PIN "
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/pwdValue"
android:layout_width="match_parent"
android:maxLength="4"
android:maxLines="1"
android:inputType="numberPassword"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
首次启动应用程序时的 LogCat
02-24 20:38:10.700 13795-13795/? I/art: Late-enabling -Xcheck:jni
02-24 20:38:10.746 13795-13795/com.developersqueen.wishlater W/asset: No ResTable, no resources need to be removed or added
02-24 20:38:10.755 13795-13795/com.developersqueen.wishlater W/System: ClassLoader referenced unknown path: /data/app/com.developersqueen.wishlater-1/lib/arm64
02-24 20:38:10.757 13795-13795/com.developersqueen.wishlater I/InstantRun: Instant Run Runtime started. Android package is com.developersqueen.wishlater, real application class is null.
02-24 20:38:10.946 13795-13795/com.developersqueen.wishlater W/System: ClassLoader referenced unknown path: /data/app/com.developersqueen.wishlater-1/lib/arm64
02-24 20:38:11.179 13795-13795/com.developersqueen.wishlater W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat. updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
02-24 20:38:11.521 13795-13795/com.developersqueen.wishlater I/Timeline: Timeline: Activity_launch_request id:com.developersqueen.wishlater time:83965007
02-24 20:38:11.769 13795-13795/com.developersqueen.wishlater V/BoostFramework: mAcquireFunc method = public int com.qualcomm.qti.Performance.perfLockAcquire(int,int[])
02-24 20:38:11.769 13795-13795/com.developersqueen.wishlater V/BoostFramework: mReleaseFunc method = public int com.qualcomm.qti.Performance.perfLockRelease()
02-24 20:38:11.769 13795-13795/com.developersqueen.wishlater V/BoostFramework: mAcquireTouchFunc method = public int com.qualcomm.qti.Performance.perfLockAcquireTouch(android.view.MotionEvent,android.util.DisplayMetrics,int,int[])
02-24 20:38:11.769 13795-13795/com.developersqueen.wishlater V/BoostFramework: mIOPStart method = public int com.qualcomm.qti.Performance.perfIOPrefetchStart(int,java.lang.String)
02-24 20:38:11.769 13795-13795/com.developersqueen.wishlater V/BoostFramework: mIOPStop method = public int com.qualcomm.qti.Performance.perfIOPrefetchStop()
02-24 20:38:11.775 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@7268965
02-24 20:38:11.775 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@263763a
02-24 20:38:11.920 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@8ef0119
02-24 20:38:11.921 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@26f45de
02-24 20:38:11.921 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@85e93bf
02-24 20:38:11.921 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@6034a8c
02-24 20:38:12.234 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@872acdb
02-24 20:38:12.234 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@5e08378
02-24 20:38:12.332 13795-13795/com.developersqueen.wishlater W/asset: No ResTable, no resources need to be removed or added
02-24 20:38:12.465 13795-13795/com.developersqueen.wishlater W/asset: No ResTable, no resources need to be removed or added
02-24 20:38:12.469 13795-13795/com.developersqueen.wishlater D/DynamitePackage: Instantiated singleton DynamitePackage.
02-24 20:38:12.469 13795-13795/com.developersqueen.wishlater D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
02-24 20:38:12.542 13795-13857/com.developersqueen.wishlater I/DynamiteModule: Considering local module com.google.android.gms.piccard.dynamite:0 and remote module com.google.android.gms.piccard.dynamite:12
02-24 20:38:12.543 13795-13857/com.developersqueen.wishlater I/DynamiteModule: Selected remote version of com.google.android.gms.piccard.dynamite, version >= 12
02-24 20:38:12.636 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
02-24 20:38:12.661 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
02-24 20:38:12.664 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
02-24 20:38:12.672 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unsupported mime video/x-ms-wmv
02-24 20:38:12.675 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unsupported mime video/divx
02-24 20:38:12.677 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unsupported mime video/divx311
02-24 20:38:12.679 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unsupported mime video/divx4
02-24 20:38:12.688 13795-13857/com.developersqueen.wishlater W/VideoCapabilities: Unsupported mime video/mp4v-esdp
02-24 20:38:12.712 13795-13857/com.developersqueen.wishlater I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
02-24 20:38:12.764 13795-13795/com.developersqueen.wishlater I/Ads: Starting ad request.
02-24 20:38:12.790 13795-13863/com.developersqueen.wishlater I/WebViewFactory: Loading com.google.android.webview version 55.0.2883.91 (code 288309150)
02-24 20:38:12.850 13795-13863/com.developersqueen.wishlater W/asset: No ResTable, no resources need to be removed or added
02-24 20:38:12.881 13795-13795/com.developersqueen.wishlater W/ActionBarDrawerToggle: DrawerToggle may not show up because NavigationIcon is not visible. You may need to call actionbar.setDisplayHomeAsUpEnabled(true);
02-24 20:38:12.883 13795-13863/com.developersqueen.wishlater I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
02-24 20:38:12.883 13795-13863/com.developersqueen.wishlater I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
02-24 20:38:12.892 13795-13863/com.developersqueen.wishlater I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
02-24 20:38:12.893 13795-13863/com.developersqueen.wishlater I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
02-24 20:38:12.893 13795-13795/com.developersqueen.wishlater D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
02-24 20:38:12.897 13795-13795/com.developersqueen.wishlater I/Ads: Starting ad request.
02-24 20:38:12.901 13795-13863/com.developersqueen.wishlater I/cr_LibraryLoader: Time to load native libraries: 1 ms (timestamps 6385-6386)
02-24 20:38:12.901 13795-13863/com.developersqueen.wishlater I/cr_LibraryLoader: Expected native library version number "55.0.2883.91", actual native library version number "55.0.2883.91"
02-24 20:38:12.964 13795-13795/com.developersqueen.wishlater D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
02-24 20:38:12.967 13795-13795/com.developersqueen.wishlater I/Ads: Starting ad request.
02-24 20:38:12.976 13795-13795/com.developersqueen.wishlater D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
02-24 20:38:12.979 13795-13795/com.developersqueen.wishlater I/Ads: Starting ad request.
02-24 20:38:13.004 13795-13795/com.developersqueen.wishlater D/myerror: 0000
02-24 20:38:13.017 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@177cb48
02-24 20:38:13.017 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@1a1ade1
02-24 20:38:13.031 13795-13899/com.developersqueen.wishlater D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-24 20:38:13.117 13795-13899/com.developersqueen.wishlater I/Adreno: QUALCOMM build : d842ad3, Ia10634f51b
Build Date : 01/04/16
OpenGL ES Shader Compiler Version: XE031.06.00.05
Local Branch : mybranch17585849
Remote Branch : quic/LA.BR.1.2.6_rb1.7
Remote Branch : NONE
Reconstruct Branch : NOTHING
02-24 20:38:13.124 13795-13899/com.developersqueen.wishlater I/OpenGLRenderer: Initialized EGL, version 1.4
02-24 20:38:13.896 13795-13795/com.developersqueen.wishlater I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@e253f4 time:83967381
02-24 20:38:14.341 13795-13795/com.developersqueen.wishlater I/cr_LibraryLoader: Expected native library version number "55.0.2883.91", actual native library version number "55.0.2883.91"
02-24 20:38:14.342 13795-13795/com.developersqueen.wishlater I/chromium: [INFO:library_loader_hooks.cc(163)] Chromium logging enabled: level = 0, default verbosity = 0
02-24 20:38:14.377 13795-13795/com.developersqueen.wishlater I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
02-24 20:38:14.681 13795-13795/com.developersqueen.wishlater I/cr_Ime: ImeThread is enabled.
02-24 20:38:14.682 13795-13945/com.developersqueen.wishlater W/cr_media: Requires BLUETOOTH permission
02-24 20:38:14.768 13795-13795/com.developersqueen.wishlater E/chromium: [ERROR:interface_registry.cc(104)] Failed to locate a binder for interface: autofill::mojom::PasswordManagerDriver
02-24 20:38:14.782 13795-13965/com.developersqueen.wishlater E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
02-24 20:38:14.872 13795-13795/com.developersqueen.wishlater W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13795
02-24 20:38:15.413 13795-13795/com.developersqueen.wishlater D/TextView: enter getOffsetForPosition
02-24 20:38:15.468 13795-13795/com.developersqueen.wishlater D/TextView: enter getOffsetForPos ition
最小化和重新打开应用程序后的 LogCat(这次对话框效果很好)
02-24 20:38:23.988 13795-13795/com.developersqueen.wishlater I/Ads: Ad finished loading.
02-24 20:38:24.034 13795-13795/com.developersqueen.wishlater I/cr_Ime: ImeThread is enabled.
02-24 20:38:24.059 13795-13795/com.developersqueen.wishlater I/Timeline: Timeline: Activity_launch_request id:com.developersqueen.wishlater time:83977544
02-24 20:38:24.086 13795-13795/com.developersqueen.wishlater E/chromium: [ERROR:interface_registry.cc(104)] Failed to locate a binder for interface: autofill::mojom::PasswordManagerDriver
02-24 20:38:24.108 13795-13795/com.developersqueen.wishlater D/myerror: 0000
02-24 20:38:24.120 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@50e633c
02-24 20:38:24.120 13795-13795/com.developersqueen.wishlater V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@5c4b8c5
02-24 20:38:24.249 13795-13795/com.developersqueen.wishlater D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdOverlayCreatorImpl
02-24 20:38:24.268 13795-13795/com.developersqueen.wishlater I/Ads: Ad opening.
02-24 20:38:24.715 13795-13795/com.developersqueen.wishlater W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13795
02-24 20:38:24.717 13795-13795/com.developersqueen.wishlater I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/ static/mad/sdk/native/sdk-core-v40-loader.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
02-24 20:38:24.718 13795-13795/com.developersqueen.wishlater I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
02-24 20:38:24.883 13795-13795/com.developersqueen.wishlater I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@858be9 time:83978369
02-24 20:38:24.884 13795-13795/com.developersqueen.wishlater I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@858be9 time:83978369
02-24 20:38:25.765 13795-13795/com.developersqueen.wishlater I/cr_Ime: ImeThread is enabled.
02-24 20:38:25.805 13795-13795/com.developersqueen.wishlater E/chromium: [ERROR:interface_registry.cc(104)] Failed to locate a binder for interface: autofill::mojom::PasswordManagerDriver
02-24 20:38:25.820 13795-13795/com.developersqueen.wishlater W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13795
02-24 20:38:26.081 13795-13795/com.developersqueen.wishlater I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
02-24 20:38:26.255 13795-13795/com.developersqueen.wishlater I/Ads: Ad finished loading.
02-24 20:38:26.256 13795-13795/com.developersqueen.wishlater W/Ads: The interstitial is already showing.
02-24 20:38:27.782 13795-13795/com.developersqueen.wishlater I/Ads: Ad closing.
02-24 20:38:27.851 13795-13795/com.developersqueen.wishlater W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13795
02-24 20:38:27.955 13795-13795/com.developersqueen.wishlater I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@e253f4 time:83981441
02-24 20:38:29.961 13795-13795/com.developersqueen.wishlater D/TextView: enter getOffsetForPosition
02-24 20:38:30.031 13795-13795/com.developersqueen.wishlater D/TextView: enter getOffsetForPosition
02-24 20:38:35.704 13795-13795/com.developersqueen.wishlater I/cr_Ime: ImeThread is enabled.
02-24 20:38:35.705 13795-13795/com.developersqueen.wishlater E/chromium: [ERROR:interface_registry.cc(104)] Failed to locate a binder for interface: autofill::mojom::PasswordManagerDriver
02-24 20:38:35.743 13795-13805/com.developersqueen.wishlater I/art: Background partial concurrent mark sweep GC freed 10967(624KB) AllocSpace objects, 14(2MB) LOS objects, 11% free, 30MB/34MB, paused 5.169ms total 60.242ms
02-24 20:38:35.765 13795-13795/com.developersqueen.wishlater W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13795
02-24 20:38:36.140 13795-13795/com.developersqueen.wishlater I/Ads: Scheduling ad refresh 60000 milliseconds from now.
02-24 20:38:36.159 13795-13795/com.developersqueen.wishlater I/Ads: Ad finished loading.
02-24 20:38:38.669 13795-13795/com.developersqueen.wishlater I/cr_Ime: ImeThread is enabled.
02-24 20:38:38.678 13795-13795/com.developersqueen.wishlater E/chromium: [ERROR:interface_registry.cc(104)] Failed to locate a binder for interface: autofill::mojom::PasswordManagerDriver
02-24 20:38:38.753 13795-13795/com.developersqueen.wishlater W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13795
02-24 20:38:38.915 13795-13795/com.developersqueen.wishlater I/Ads: Scheduling ad refresh 60000 milliseconds from now.
02-24 20:38:38.927 13795-13795/com.developersqueen.wishlater I/Ads: Ad finished loading.