我需要从设备中选择图像并将其上传到服务器.第一次,当我选择图像时,onShowFileChooser()被调用,一切正常.但是,当我再次尝试点击上传时,onShowFileChooser()永远不会被调用.但它适用于非棒棒糖设备.每当我点击上传时,都会调用openFileChoser().有什么我想念的吗?这是我的代码:
//Needed for file upload feature
vWebView.setWebChromeClient(new WebChromeClient() {
// file upload callback (Android 2.2 (API level 8) -- Android 2.3 (API level 10)) (hidden method)
public void openFileChooser(ValueCallback<Uri> filePathCallback) {
showAttachmentDialog(filePathCallback);
}
// file upload callback (Android 3.0 (API level 11) -- Android 4.0 (API level 15)) (hidden method)
public void openFileChooser(ValueCallback filePathCallback, String acceptType) {
showAttachmentDialog(filePathCallback);
}
// file upload callback (Android 4.1 (API level 16) -- Android 4.3 (API level 18)) (hidden method)
public void openFileChooser(ValueCallback<Uri> filePathCallback, …Run Code Online (Sandbox Code Playgroud) 我有一个分享按钮GCM notification.点击分享按钮,我需要启动分享意图.一切都很完美.我面临的唯一问题是Lollipop锁屏功能.当我从锁定屏幕单击共享按钮时,我的意图对话框出现在锁定屏幕下方,用户必须解锁屏幕才能看到对话框.单击共享按钮时,我想以编程方式解锁屏幕.
我尝试使用Power Manager,但是它的所有wakeClock标志都已弃用并且WindowManager.LayoutParams.Flag_KEEP_SCREEN_ON建议使用.但我不是在这里使用活动.我正在使用broadcastReciever context.因此我不能使用getWindow()方法.
我也尝试过KeyguardManager.但即便disableKeyguard()被解除了.
Intent.ACTION_SCREEN_ON如果我们想在屏幕解锁后执行任何操作,我不能使用,因为这应该使用.
我曾使用以下意图以编程方式关闭通知托盘:
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mContext.sendBroadcast(it);
Run Code Online (Sandbox Code Playgroud)
是否有类似的意图,可以广播解锁屏幕
使用DevicePolicyManager更新了代码:
public static void handleShareBtnClick(Context context, String message) {
GcmHelper helper = new GcmHelper();
helper.shareMessage(context, message);
if(Utility.isLollypopAndAbove()){
helper.unlockLockScreen();
}
helper.launchShareforForAlert();
}
public void unlockLockScreen(){
DevicePolicyManager devicePolicyMngr= (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName compName=new ComponentName(mContext, DeviceAdminReceiver.class);
if(!devicePolicyMngr.isAdminActive(compName))
devicePolicyMngr.removeActiveAdmin(compName);
}
Run Code Online (Sandbox Code Playgroud)
即使在使用DevicePolicyManager之后,它也无法解锁我的屏幕
我想分享GCM通知项目.共享按钮响应点击事件,项目也被共享.这里唯一的问题是,通知托盘下方有Intent选择器对话框.用户必须手动关闭状态栏,然后选择要共享的应用程序.我想以编程方式关闭状态栏,以便当用户单击共享时,它会直接向他显示选择应用程序的对话框.
我发现该status bar服务可用于打开/关闭服务.但它仅限于系统应用程序.
private void closeNotificationTray() {
Object service = mContext.getSystemService(Context.STATUS_BAR_SERVICE);
Method collapse;
try {
Class<?> statusBarMngr = Class.forName("android.app.StatusBarManager");
if (Build.VERSION.SDK_INT >= 17)
collapse = statusBarMngr.getMethod("collapsePanels");
else
collapse = statusBarMngr.getMethod("collapse");
collapse.invoke(service);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我用了上面的代码.但我得到"STATUS_BAR_SERVICE无法重新发送"错误.当我在清单中添加以下权限时:
<uses-permission
android:name="android.permission.STATUS_BAR" />
Run Code Online (Sandbox Code Playgroud)
我得到了,只允许系统apps.It不允许我在我的应用程序中使用.有没有办法使用status bar服务或任何其他替代方案?
更新:
我用2行代码解决了上述问题.无需调用STATUS_BAR_SERVICE.
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mContext.sendBroadcast(it);
Run Code Online (Sandbox Code Playgroud)
调用此意图将自动关闭通知
我想删除标签之间的内容<script></script>。我正在手动检查模式并iterating使用 while 循环。但是,我正在了解StringOutOfBoundException这一行:
String script = source.substring(startIndex,endIndex-startIndex);
Run Code Online (Sandbox Code Playgroud)
下面是完整的方法:
String script = source.substring(startIndex,endIndex-startIndex);
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么吗?我正在得到endIndex=-1。任何人都可以帮助我确定为什么我的代码被破坏。
android ×3
filechooser ×1
html ×1
html-parsing ×1
java ×1
keyguard ×1
statusbar ×1
unlock ×1
webview ×1