Android隐藏Launcher Icon

android Activity

<category android:name="android.intent.category.LAUNCHER" />

添加此内容后会产生入口icon给用户,点击进入此Activity。例如想用包名启动某个LauncherActivity:

public static boolean openAppByPname(Context context, String pName) {
		boolean isOk = false;
		try {
			Intent intent = context.getPackageManager()
					.getLaunchIntentForPackage(pName);
			intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(intent);

			isOk = true;
		} catch (Exception e) {
			MyLog.printLog(e);
		}
		return isOk;
	}

但是我不想让用户看见这个入口icon,原因..

1.直接不给Activity设置Launcher,想启动应用直接打开某个Activity好了。例如:

adb shell am start -n com.package/com.package.MainActivity


2.启动应用后让入口icon做个隐藏处理

public static boolean hideLauncherIcon(Context context) {
		boolean isOk = false;
		try {
			PackageManager packageManager = context.getPackageManager();
			packageManager.setComponentEnabledSetting(
					((Activity) context).getComponentName(),
					PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
					PackageManager.DONT_KILL_APP);

			isOk = true;
		} catch (Exception e) {
			MyLog.printLog(e);
		}
		return isOk;

这个方法我在几个测试机上测试是ok的,说是某些设备上貌似从启设备才长生效果,这个需要再验证下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你想在 Android 10 中的启动器图标上添加圆角,可以使用以下步骤: 1. 首先,在你的 `drawable` 文件夹中创建一个新的图标资源文件,并命名为 `ic_launcher_round.xml`。 2. 在文件中添加以下代码: ```xml <?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/ic_launcher_background"/> <foreground android:drawable="@drawable/ic_launcher_foreground"/> </adaptive-icon> ``` 这段代码定义了一个自适应图标,并将背景设置为 `ic_launcher_background` 资源文件中的颜色,将前景设置为 `ic_launcher_foreground` 资源文件中的图标。 3. 接下来,在 `values` 文件夹中的 `styles.xml` 文件中添加以下代码: ```xml <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:roundIcon">@drawable/ic_launcher_round</item> </style> ``` 这段代码将你的应用程序主题与新的启动器图标关联起来。 4. 最后,在 `AndroidManifest.xml` 文件中的 `application` 标签中添加以下代码: ```xml <application ... android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round"> ... </application> ``` 这段代码将应用程序的默认图标设置为 `ic_launcher` 资源文件中的图标,并将圆角图标设置为 `ic_launcher_round` 资源文件中的图标。 完成这些步骤后,你的应用程序的启动器图标应该具有圆角效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值