[英]How to handle home key to redirect application using intent chooser?
In our application we have to open pdf file through application.Our application nothing but pdfviewer. 在我们的应用程序中,我们必须通过application.pdf打开文件。我们的应用程序只有pdfviewer。 I have referred ( Why isn't my app on the list of apps to open txt file? ) this link.
我已经提到了( 为什么我的应用程序不在打开txt文件的应用程序列表中? )。 It works fine for me.
这对我来说可以。 In case if i click on home button , and tried to open another pdf from file explorer it redirects to my application.
如果我单击主页按钮,并尝试从文件资源管理器中打开另一个pdf,它将重定向到我的应用程序。 Please look into this.
请调查一下。
Thanks, AA. 谢谢,机管局。
Here is a possible solution: 这是一个可能的解决方案:
Override below method in your activity. 在您的活动中覆盖以下方法。
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
}
After overriding above method, now you can easily listen HOME Key press in your activity using onKeyDown() method. 覆盖上述方法之后,现在您可以使用onKeyDown()方法轻松监听活动中的HOME键按下。
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_HOME)
{
//The Code Want to Perform.
}
});
Reference: http://nisha113a5.blogspot.com/ 参考: http : //nisha113a5.blogspot.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.