简体   繁体   English

如何从电话拨号器中调出隐藏的应用程序?

[英]how can i recall a hidden app from phone dialer?

我的最终项目要求必须隐藏该应用程序,除非在电话拨号器中输入一些代码(例如:*123#),否则永远不要再打开它,你能帮我完成这项任务吗?

This is a bit tricky and it has its up and downs, but what you need to do basically is:这有点棘手,它有起有落,但您需要做的基本上是:

  1. On app install, you need to programmatically disable the app Icon so you cannot open it manually.在应用安装时,您需要以编程方式禁用应用图标,这样您就无法手动打开它。
  2. Have a BroadcastReceiver registered with the PROCESS_OUTGOING_CALLS intent filter (don't forget to set the uses-permissions ).将 BroadcastReceiver 注册到PROCESS_OUTGOING_CALLS意图过滤器(不要忘记设置uses-permissions )。
  3. In the receiver, listen for every dialed number and when it matches yours you need to activate the App Icon again and then you start the activity with possibly extra data to handle it later.在接收器中,收听每个拨打的号码,当它与您的号码匹配时,您需要再次激活应用程序图标,然后您可能会使用额外的数据开始活动以供稍后处理。
  4. After processing the data in your activity remember to deactivate the icon again.处理完活动中的数据后,请记住再次停用该图标

To programmatically disable the icon use:要以编程方式禁用图标,请使用:

PackageManager packageManager = getPackageManager();
            ComponentName componentName = new ComponentName(this, MainActivity.class);
            packageManager.setComponentEnabledSetting(
                    componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP
            );

To enable it:要启用它:

 PackageManager packageManager = context.getPackageManager();
                ComponentName componentName = new ComponentName(context, MainActivity.class);
                packageManager.setComponentEnabledSetting(
                        componentName,PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP
                );

In your receiver to get the dialed number you need to use:在您的接收器中获取您需要使用的拨号号码:

if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
     String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

     // Validate and start your activity here
     // To start an activity from a receiver you need to use the flag FLAG_ACTIVITY_NEW_TASK in your intent
}

Note: After hiding the icon programmatically you might want to finish() the activity so it closes automatically at first run.注意:以编程方式隐藏图标后,您可能希望finish()活动,以便在第一次运行时自动关闭。

PS I have a working sample of this, so rest assured as I have tested it actually works, sadly I cannot spoon feed you in your final project. PS我有一个工作样本,所以请放心,因为我已经测试过它确实有效,遗憾的是我不能在你的最终项目中用勺子喂你。 Don't hesitate to ask anything tho.不要犹豫,问任何事情。 Good luck祝你好运

There is no such functionality in Android. Android 中没有这样的功能。 You may be able to do it with a custom home screen, but there is no "hide this app" functionality in the default launcher.您也许可以使用自定义主屏幕来执行此操作,但默认启动器中没有“隐藏此应用程序”功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查是否安装了拨号器应用程序? - How can I check if dialer app is installed? Android隐藏应用程序从拨号器启动 - Android Hidden App start from dialer 如何制作一个按钮以在电话拨号器中显示号码 - How can I make a button to show a number in the phone dialer 如何从Firebase解析如何将数据从RecyclerView持有者传递到电话应用程序拨号器 - How to Pass data to phone app dialer from recyclerview holder data is parse from firebase 电话通话结束后,将拨号器应用程序从后台置于前台 - Bring dialer app into foreground from background when phone call is finished 在通话中如何通过编程方式在电话拨号屏幕中设置号码? - How can i set number in phone dialer screen programatically while in telephone call? 如何让拨号器打开并显示电话号码? - How do I get the dialer to open with phone number displayed? 如何从源代码构建Dialer / Phone应用程序? - How to build Dialer/Phone application from the source code? 如何像Android Dialer应用程序一样在TextView中添加大小写字母? - How can I add big AND small letters in a TextView like in the Android Dialer app? 如何避免我的混合应用程序出现在 Android 拨号器上? - How can I avoid having my hybrid app showing up on the Android dialer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM