How to hide application icon?
来源:互联网 发布:七天网络阅卷app 编辑:程序博客网 时间:2024/05/20 05:55
To Hide app icon from launcher programatically you can do this
PackageManager packageManager = context.getPackageManager(); ComponentName componentName = new ComponentName(context, LauncherActivity.class); packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
For example, We want to disable camera-related activities if there is no camera.
Firstly, register receiver in manifest file, This receiver runs when BOOT_COMPLETED intent is received.
<receiver android:name=".DisableCameraReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>
Then create a receiver class
public class DisableCameraReceiver extends BroadcastReceiver { private static final String TAG = "DisableCameraReceiver"; @Override public void onReceive(Context context, Intent intent) { // Disable camera-related activities if there is no camera. boolean needCameraActivity = hasCamera(); if (!needCameraActivity) { Log.i(TAG, "disable all camera activities"); ComponentName name = new ComponentName(context, "com.android.camera.Camera"); PackageManager pm = context.getPackageManager(); int enable_state = pm.getComponentEnabledSetting(name); // We need the DONT_KILL_APP flag, otherwise we will be killed immediately because we are in the same app. if (enable_state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } } }}
- How to hide application icon?
- How to hide the New! icon or control how long the icon is displayed.
- How to create a Symbian application icon (SVG)
- How to set the QT Application icon in the windows.
- How to embed an icon in a Qt application
- How to hide uitabbarcontroller
- How to hide ImmersiveModeConfirmation
- How to hide the OK button in the dialog in .Net Compact Framework application?
- How to add shortcut icon
- How to develop application
- How to hide the web part toolbar
- How to capture application log
- How to close Android application?
- hide app icon
- How to launch application to start->run
- How to hide the highlight of a listbox
- How to show/hide a set of elements?
- How to hide an attribute on the grid?
- 堆 和 栈的 区别(经典)
- 微软宣布推出Windows Embedded Compact 2013正式版
- 一个不错的C#博客
- 多线程同步与互斥
- android环境的搭配
- How to hide application icon?
- 保护眼睛:把白皑皑的窗口变成淡淡的绿
- ADO.NET数据库SQL操作步骤
- 从static关键字说起
- 移植最新版WordPress 3.5.1 到SAE上,可以上传附件
- WINDOW_JAVA环境变量设置
- ubuntu12.0.4 安装eclipse
- Android 4.1源码编译找不到资源文件解决办法
- linux网络编程之System V 信号量(一):封装一个信号量集操作函数的工具